Changeset 3899

Show
Ignore:
Timestamp:
10/12/05 02:51:36 (3 years ago)
Author:
horiguti
Message:

Support frame alpha. If frame parameter is a number or cons or list of
numbers, set window style WS_EX_LAYERED and alpha value.

(set-frame-parameter FRAME 'alpha nil) ;; default
(set-frame-parameter FRAME 'alpha ACTIVE)
(set-frame-parameter FRAME 'alpha '(ACTIVE . INACTIVE))
(set-frame-parameter FRAME 'alpha '(ACTIVE INACTIVE MOVING))
ACTIVE, INACTIVE, MOVING is frame alpha values (integer, 0-100) when
frame is active, inactive, moving.

mw32-frame-alpha-lower-limit is lower limit of alpha values.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/ChangeLog.Meadow

    r3898 r3899  
     12005-10-12  Kyotaro HORIGUCHI  <horiguti@meadowy.org> 
     2 
     3        * frame.c (frame_parms): New frame parameter "alpha". 
     4 
     5        * mw32fns.c: include <windows.h> to use 
     6        SetLayeredWindowAttributes. 
     7        (Qalpha): New symbol. 
     8        (mw32-frame-alpha-lower-limit): New LISP variable. 
     9        (mw32_update_frame_alpha): New extern. 
     10        (mw32_set_frame_alpha): New function. 
     11        (mw32_WndProc<WM_MOVING>): New message handler. 
     12        (mw32_window): Setup initial frame alpha. 
     13        (x-create-frame): Initiallize frame parameters *-alpha. 
     14        (mw32i_frame_parm_handlers): Add frame parm handler 
     15        mw32_set_frame_alpha. 
     16 
     17        * mw32term.h(struct mw32_output): New four members active_alpha, 
     18        inactive_alpha, moving_alpha, and current_alpha. 
     19 
     20        * mw32term.c: include <windows.h> to use 
     21        SetLayeredWindowAttributes. 
     22        (mw32_update_frame_alpha): New function. 
     23        (MW32_update_end): Refresh layered window when frame alpha is set. 
     24 
    1252005-10-12  Kyotaro HORIGUCHI  <horiguti@meadowy.org> 
    226 
  • trunk/src/frame.c

    r3809 r3899  
    26022602#endif 
    26032603  {"cursor-height",             0}, 
     2604  {"alpha",                     0}, 
    26042605#endif 
    26052606}; 
  • trunk/src/mw32fns.c

    r3886 r3899  
    2121 
    2222/* MW32 implementation by MIYASHITA Hisashi <himi@meadowy.org> */ 
     23 
     24/* This is included to use SetLayeredWindowAttributes() */ 
     25#define _WIN32_WINNT 0x0500 
     26#include <windows.h> 
    2327 
    2428#include <config.h> 
     
    98102Lisp_Object Qbox; 
    99103Lisp_Object Qcursor_height; 
     104Lisp_Object Qalpha; 
    100105Lisp_Object Qnone; 
    101106Lisp_Object Qouter_window_id; 
     
    112117/* The ANSI codepage.  */ 
    113118int w32_ansi_code_page; 
     119 
     120/* Lower limit of alpha value of frame. */ 
     121int mw32_frame_alpha_lower_limit; 
    114122 
    115123#if GLYPH_DEBUG 
     
    924932} 
    925933 
     934/* defined in mw32term.c */ 
     935extern void mw32_update_frame_alpha (struct frame *f, int change_style); 
     936 
     937static void 
     938mw32_set_frame_alpha (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) 
     939{ 
     940  int oldalpha= f->output_data.mw32->current_alpha; 
     941  int newalpha_active, newalpha_inactive, newalpha_moving, newalpha; 
     942  int obj; 
     943 
     944  if (NILP (arg)) 
     945    newalpha_active = newalpha_inactive = -1; 
     946  else 
     947    { 
     948      if (NUMBERP (arg)) 
     949        { 
     950          newalpha_active = XINT (arg); 
     951           
     952          if (newalpha_active < 0 || newalpha_active > 100) 
     953            args_out_of_range (make_number (0), make_number (100)); 
     954           
     955          newalpha_inactive = newalpha_moving = newalpha_active; 
     956        } 
     957      else if (CONSP (arg)) 
     958        { 
     959          if (! NUMBERP (CAR (arg))) 
     960            wrong_type_argument (Qnumberp, (CAR (arg))); 
     961          newalpha_active = XINT (CAR (arg)); 
     962           
     963          if (NUMBERP (CDR (arg))) 
     964            newalpha_inactive = XINT (CDR (arg)); 
     965          else if (CONSP (CDR (arg)) && NUMBERP (CAR (CDR (arg)))) 
     966            newalpha_inactive = XINT (CAR (CDR (arg))); 
     967          else 
     968            wrong_type_argument (Qnumberp, (CDR (arg))); 
     969           
     970          newalpha_moving = newalpha_active; 
     971           
     972          if (newalpha_active > 100 || newalpha_active < 0 
     973              || newalpha_inactive > 100 || newalpha_inactive < 0) 
     974            args_out_of_range (make_number (0), make_number (100)); 
     975           
     976          if (CONSP (CDR (arg))) 
     977            { 
     978              if (Flength (arg) > 2) 
     979                { 
     980                  obj = (CAR (CDR (CDR (arg)))); 
     981                  if (! NUMBERP (obj)) 
     982                    wrong_type_argument (Qnumberp, obj); 
     983                  newalpha_moving = XINT (obj); 
     984                   
     985                  if (newalpha_moving > 100 || newalpha_moving < 0) 
     986                    args_out_of_range (make_number (0), make_number (100)); 
     987                } 
     988            } 
     989        } 
     990      else 
     991        wrong_type_argument (Qnumberp, arg); 
     992 
     993      /* Apply lower limit silently */ 
     994      if (newalpha_active < mw32_frame_alpha_lower_limit) 
     995        newalpha_active = mw32_frame_alpha_lower_limit; 
     996      if (newalpha_inactive < mw32_frame_alpha_lower_limit) 
     997        newalpha_inactive = mw32_frame_alpha_lower_limit; 
     998      if (newalpha_moving < mw32_frame_alpha_lower_limit) 
     999        newalpha_moving = mw32_frame_alpha_lower_limit; 
     1000    } 
     1001   
     1002  f->output_data.mw32->active_alpha = newalpha_active;   
     1003  f->output_data.mw32->inactive_alpha = newalpha_inactive;   
     1004  f->output_data.mw32->moving_alpha = newalpha_moving;   
     1005 
     1006  mw32_update_frame_alpha (f, TRUE); 
     1007} 
     1008 
    9261009  
    9271010#ifdef IME_CONTROL 
     
    18661949    return 0; 
    18671950 
     1951  case WM_MOVING: 
     1952    if (f->output_data.mw32->moving_alpha >= 0  
     1953        && f->output_data.mw32->current_alpha >= 0 
     1954        && (f->output_data.mw32->moving_alpha !=  
     1955            f->output_data.mw32->current_alpha)) 
     1956      { 
     1957        SetLayeredWindowAttributes(FRAME_MW32_WINDOW (f), 
     1958                                   RGB(255, 255, 255), 
     1959                                   (int) 
     1960                                   ((float)(f->output_data.mw32->moving_alpha) 
     1961                                    /(float)100*(float)255), 
     1962                                   LWA_ALPHA); 
     1963        f->output_data.mw32->current_alpha 
     1964          = f->output_data.mw32->moving_alpha; 
     1965      } 
     1966    return 0; 
     1967 
    18681968  case WM_MOVE: 
    18691969 
     
    19002000          f->top_pos = rect.top; 
    19012001          SET_FRAME_GARBAGED (f); 
     2002          mw32_update_frame_alpha (f, FALSE); 
    19022003        } 
    19032004      } 
     
    25702671  if (FRAME_MW32_WINDOW (f) == 0) 
    25712672    error ("Unable to create window"); 
     2673 
     2674  mw32_update_frame_alpha (f, TRUE); 
    25722675} 
    25732676 
     
    27022805  f->output_data.mw32->hdc = INVALID_HANDLE_VALUE; 
    27032806  f->output_data.mw32->message_thread_hdc = INVALID_HANDLE_VALUE; 
     2807  f->output_data.mw32->current_alpha = -1; 
     2808  f->output_data.mw32->active_alpha = -1; 
     2809  f->output_data.mw32->inactive_alpha = -1; 
     2810  f->output_data.mw32->moving_alpha = -1; 
    27042811  { 
    27052812    LOGFONT lf; 
     
    29283035  x_default_parameter (f, parameters, Qscroll_bar_width, Qnil, 
    29293036                       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER); 
     3037  x_default_parameter (f, parameters, Qalpha, Qnil, 
     3038                       "alpha", "Alpha", RES_TYPE_NUMBER); 
    29303039 
    29313040  /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size. 
     
    46304739  mw32_set_frame_ime_font, 
    46314740#endif 
    4632   mw32_set_cursor_height 
     4741  mw32_set_cursor_height, 
     4742  mw32_set_frame_alpha 
    46334743}; 
    46344744 
     
    46604770  Qcursor_height = intern ("cursor-height"); 
    46614771  staticpro (&Qcursor_height); 
     4772  Qalpha = intern ("alpha"); 
     4773  staticpro (&Qalpha); 
    46624774  Qnone = intern ("none"); 
    46634775  staticpro (&Qnone); 
     
    47574869  w32_ansi_code_page = GetACP (); 
    47584870 
     4871  DEFVAR_INT ("mw32-frame-alpha-lower-limit", &mw32_frame_alpha_lower_limit, 
     4872              doc: /* Lower limit of alpha value of frame. */); 
     4873  mw32_frame_alpha_lower_limit = 20; 
     4874 
    47594875  defsubr (&Sxw_display_color_p); 
    47604876  defsubr (&Sx_display_grayscale_p); 
  • trunk/src/mw32term.c

    r3898 r3899  
    3939 
    4040#include <stdio.h> 
     41 
     42/* This is included to use SetLayeredWindowAttributes() */ 
     43#define _WIN32_WINNT 0x0500 
     44#include <windows.h> 
     45#ifdef WHEEL_PAGESCROLL 
     46#undef WHEEL_PAGESCROLL 
     47#endif 
    4148 
    4249#include "lisp.h" 
     
    695702 
    696703 
     704/* Change alpha of frame. */ 
     705void 
     706mw32_update_frame_alpha (struct frame *f, int change_style) 
     707{ 
     708  int newalpha, oldalpha; 
     709 
     710  oldalpha = f->output_data.mw32->current_alpha; 
     711 
     712  if (FRAME_MW32_DISPLAY_INFO (f)->mw32_highlight_frame == f) 
     713    newalpha = f->output_data.mw32->active_alpha; 
     714  else 
     715    newalpha = f->output_data.mw32->inactive_alpha; 
     716 
     717  if (change_style) 
     718    {     
     719      if (newalpha < 0 && oldalpha >= 0) 
     720        SetWindowLong (FRAME_MW32_WINDOW (f),GWL_EXSTYLE, 
     721                       GetWindowLong (FRAME_MW32_WINDOW (f), GWL_EXSTYLE) 
     722                       & ~WS_EX_LAYERED); 
     723      else if (newalpha >= 0 && oldalpha < 0) 
     724        SetWindowLong (FRAME_MW32_WINDOW (f),GWL_EXSTYLE, 
     725                       GetWindowLong (FRAME_MW32_WINDOW (f), GWL_EXSTYLE) 
     726                       | WS_EX_LAYERED); 
     727    } 
     728  /* Caloing SetLayeredWindowAttributes to update displaed frame image 
     729     when alpha is used. */ 
     730  if (newalpha >= 0) 
     731    SetLayeredWindowAttributes(FRAME_MW32_WINDOW (f), 
     732                               RGB(255, 255, 255), 
     733                               (int) 
     734                               ((float)newalpha 
     735                                /(float)100*(float)255), 
     736                               LWA_ALPHA); 
     737   
     738  f->output_data.mw32->current_alpha = newalpha; 
     739} 
     740 
    697741/* End update of frame F.  This function is installed as a hook in 
    698742   update_end.  */ 
     
    703747  /* Mouse highlight may be displayed again.  */ 
    704748  if (FRAME_MW32_P (f)) 
    705     FRAME_MW32_DISPLAY_INFO (f)->mouse_face_defer = 0; 
     749    { 
     750      FRAME_MW32_DISPLAY_INFO (f)->mouse_face_defer = 0; 
     751      /* This is necessary to display updates when alpha > -1 */ 
     752      mw32_update_frame_alpha (f, FALSE); 
     753    } 
    706754} 
    707755 
  • trunk/src/mw32term.h

    r3871 r3899  
    477477  /* logfont for IME  */ 
    478478  LOGFONT ime_logfont; 
     479 
     480  /* Transparent frame. Range is -1 to 100, -1 means alpha disabled. */ 
     481  int active_alpha;    /* Alpha value when this frame is active     */ 
     482  int inactive_alpha;  /* Alpha value when this frame is inactive   */ 
     483  int moving_alpha;    /* Alpha value when this frame is under move */ 
     484  int current_alpha;   /* Current alpha value of this frame */ 
    479485}; 
    480486