Changeset 3925

Show
Ignore:
Timestamp:
10/20/05 00:48:00 (3 years ago)
Author:
horiguti
Message:

Reconstruct mouse cursor hiding functions. See ticket:205

Files:

Legend:

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

    r3924 r3925  
     12005-10-19  Kyotaro HORIGUCHI  <horiguti@meadowy.org> 
     2 
     3        * mw32term.c (show_or_hide_mouse_cursor): Reconstruct code. See 
     4        ticket:205 . 
     5        (show_or_hide_mouse_cursor<WM_MOUSELEAVE>): Don't change 
     6        current_cursor of current frame when leaving client area. 
     7        (w32-hide-mouse-stickiness): New variable. See ticket:205 
     8        (w32-hide-mouse-timeout): Change meaning. See ticket:205 
     9        (w32-hide-mouse-on-key): Ditto. 
     10        (w32-hide-mouse-by-wheel): Ditto. 
     11 
    1122005-10-18  MIYOSHI Masanori  <miyoshi@meadowy.org> 
    213 
  • trunk/src/mw32term.c

    r3923 r3925  
    37143714int mw32_mbutton_to_emacs_button; 
    37153715int mw32_lbutton_to_emacs_button; 
    3716 int mw32_hide_mouse_timeout; 
    3717 int mw32_hide_mouse_on_key; 
     3716int mw32_hide_mouse_stickiness = 0; 
     3717Lisp_Object mw32_hide_mouse_timeout; 
     3718Lisp_Object mw32_hide_mouse_on_key; 
    37183719Lisp_Object mw32_hide_mouse_by_wheel; 
    37193720 
     
    41984199{ 
    41994200  static unsigned int mouse_hide_timer = 0; 
    4200   static int hidden_by_wheel = 0; 
    4201   static POINT hidden_by_wheel_point; 
    4202   int hidden_by_wheel_insensitive_range = 10; 
     4201  static POINT lastpos; 
     4202  static int insensitive_range = 0; 
     4203  static int last_timeout_obj_init_p = 0; 
     4204  static Lisp_Object last_timeout_obj; 
     4205  static timeout; 
    42034206 
    42044207  if (mw32_inhibit_hide_mouse) 
     
    42074210          ShowCursor (TRUE); 
    42084211      dpyinfo->mouse_cursor_stat = 0; 
    4209       hidden_by_wheel = 0; 
    42104212 
    42114213      if (dpyinfo->mouse_face_hidden) 
     
    42174219      return; 
    42184220    } 
    4219        
    4220   if (mw32_hide_mouse_timeout > 0 
     4221 
     4222  if (! last_timeout_obj_init_p 
     4223      || last_timeout_obj != mw32_hide_mouse_timeout) 
     4224    { 
     4225      last_timeout_obj = mw32_hide_mouse_timeout; 
     4226      last_timeout_obj_init_p = 1; 
     4227 
     4228      if (NILP (mw32_hide_mouse_timeout)) 
     4229        timeout = 0; 
     4230      else if (NUMBERP (mw32_hide_mouse_timeout)) 
     4231        timeout = XINT (mw32_hide_mouse_timeout); 
     4232      else if (CONSP (mw32_hide_mouse_timeout) 
     4233               && NUMBERP (CAR (mw32_hide_mouse_timeout))) 
     4234        timeout = XINT (CAR (mw32_hide_mouse_timeout)); 
     4235    } 
     4236 
     4237  if (timeout > 0 
    42214238      && mouse_hide_timer == 0 
    42224239      && dpyinfo->mouse_cursor_stat == 0) 
    42234240    mouse_hide_timer = SetTimer (msg.hwnd, MW32_MOUSE_HIDE_TIMER_ID, 
    4224                                  mw32_hide_mouse_timeout, 
    4225                                  NULL); 
     4241                                 timeout, NULL); 
    42264242 
    42274243  switch (msg.message) 
     
    42314247 
    42324248    case WM_NCMOUSEMOVE: 
    4233       if (hidden_by_wheel && NUMBERP (mw32_hide_mouse_by_wheel)) 
    4234         hidden_by_wheel_insensitive_range = XINT (mw32_hide_mouse_by_wheel); 
    4235          
    4236            
    4237       if (hidden_by_wheel 
    4238           ? ((abs (LOWORD (msg.lParam) - hidden_by_wheel_point.x) 
    4239               > hidden_by_wheel_insensitive_range) 
    4240              || (abs (HIWORD (msg.lParam) - hidden_by_wheel_point.y) 
    4241                  > hidden_by_wheel_insensitive_range)) 
    4242           : last_mouse_motion_message.lParam != msg.lParam) 
     4249      if (msg.lParam != last_mouse_motion_message.lParam) 
    42434250        { 
     4251          if (insensitive_range < 0) 
     4252            { 
     4253              lastpos.x = LOWORD (last_mouse_motion_message.lParam); 
     4254              lastpos.y = HIWORD (last_mouse_motion_message.lParam); 
     4255            } 
     4256 
    42444257          last_mouse_motion_message = msg; 
    42454258          last_mouse_movement_time = msg.time; 
    42464259 
    4247           hidden_by_wheel = 0; 
    4248  
    4249           if (dpyinfo->mouse_cursor_stat < 0) 
     4260           
     4261          if ((abs (LOWORD (msg.lParam) - lastpos.x) 
     4262               > abs (insensitive_range)) 
     4263              || (abs (HIWORD (msg.lParam) - lastpos.y) 
     4264                  > abs (insensitive_range))) 
    42504265            { 
    4251               dpyinfo->mouse_cursor_stat = 0; 
    4252               ShowCursor (TRUE); 
    4253             } 
    4254           if (dpyinfo->mouse_face_hidden) 
    4255             {    
    4256               dpyinfo->mouse_face_hidden = 0; 
    4257               clear_mouse_face (dpyinfo); 
     4266              if (dpyinfo->mouse_cursor_stat < 0) 
     4267                { 
     4268                  dpyinfo->mouse_cursor_stat = 0; 
     4269                  ShowCursor (TRUE); 
     4270                } 
     4271              if (dpyinfo->mouse_face_hidden) 
     4272                {        
     4273                  dpyinfo->mouse_face_hidden = 0; 
     4274                  clear_mouse_face (dpyinfo); 
     4275                } 
    42584276            } 
    42594277        } 
     
    42644282        { 
    42654283          /* If we've had mouse motion after last SetTimer, extend timeout. */ 
    4266           if (msg.time - last_mouse_movement_time < mw32_hide_mouse_timeout 
     4284          if (msg.time - last_mouse_movement_time < timeout 
    42674285              && dpyinfo->mouse_cursor_stat == 0) 
    42684286            { 
    42694287              int extend_mills = 
    4270                 mw32_hide_mouse_timeout - (msg.time - last_mouse_movement_time); 
     4288                timeout - (msg.time - last_mouse_movement_time); 
    42714289               
    4272               mouse_hide_timer = SetTimer (msg.hwnd, MW32_MOUSE_HIDE_TIMER_ID
     4290              mouse_hide_timer = SetTimer (msg.hwnd, mouse_hide_timer
    42734291                                           extend_mills, NULL); 
    42744292            } 
     
    42814299                  ShowCursor (FALSE); 
    42824300                  dpyinfo->mouse_cursor_stat = -1; 
    4283                   hidden_by_wheel = 0; 
     4301 
     4302                  insensitive_range = mw32_hide_mouse_stickiness; 
     4303                  if (CONSP (mw32_hide_mouse_timeout)) 
     4304                    { 
     4305                      if (NUMBERP (CDR (mw32_hide_mouse_timeout))) 
     4306                        insensitive_range = 
     4307                          XINT (CDR (mw32_hide_mouse_timeout)); 
     4308                      else if (CONSP (CDR (mw32_hide_mouse_timeout)) && 
     4309                               NUMBERP (CAR (CDR (mw32_hide_mouse_timeout)))) 
     4310                        insensitive_range = 
     4311                          XINT (CAR (CDR (mw32_hide_mouse_timeout))); 
     4312                    } 
     4313                   
     4314                  lastpos.x = LOWORD (last_mouse_motion_message.lParam); 
     4315                  lastpos.y = HIWORD (last_mouse_motion_message.lParam); 
    42844316 
    42854317                  if (!dpyinfo->mouse_face_hidden 
     
    43044336        }       
    43054337      dpyinfo->mouse_face_hidden = 0; 
    4306       hidden_by_wheel = 0; 
    43074338       
    4308       FRAME_MW32_OUTPUT (XFRAME (selected_frame))->current_cursor 
    4309         = FRAME_MW32_OUTPUT (XFRAME (selected_frame))->nontext_cursor; 
    4310       SetCursor (FRAME_MW32_OUTPUT (XFRAME (selected_frame))->current_cursor); 
     4339      SetCursor (FRAME_MW32_OUTPUT (XFRAME (selected_frame))->nontext_cursor); 
    43114340 
    43124341      break; 
     
    43534382 
    43544383    case WM_KEYDOWN: 
    4355       if (mw32_hide_mouse_on_key && dpyinfo->mouse_cursor_stat == 0) 
     4384      if (! NILP (mw32_hide_mouse_on_key) && dpyinfo->mouse_cursor_stat == 0) 
    43564385        { 
    43574386          dpyinfo->mouse_cursor_stat = -1; 
    43584387          ShowCursor (FALSE); 
    4359           hidden_by_wheel = 0; 
     4388 
     4389          insensitive_range = mw32_hide_mouse_stickiness; 
     4390          if (NUMBERP (mw32_hide_mouse_on_key)) 
     4391            insensitive_range = XINT (mw32_hide_mouse_on_key); 
     4392          lastpos.x = LOWORD (last_mouse_motion_message.lParam); 
     4393          lastpos.y = HIWORD (last_mouse_motion_message.lParam); 
    43604394 
    43614395          if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) 
     
    43734407#ifdef W32_INTELLIMOUSE 
    43744408    case WM_MOUSEWHEEL: 
    4375       hidden_by_wheel_point.x = LOWORD (msg.lParam); 
    4376       hidden_by_wheel_point.y = HIWORD (msg.lParam); 
    4377       ScreenToClient (FRAME_MW32_WINDOW (XFRAME (selected_frame)), 
    4378                       &hidden_by_wheel_point); 
    4379  
    4380       if (! NILP (mw32_hide_mouse_by_wheel) && dpyinfo->mouse_cursor_stat == 0) 
     4409      if (! NILP (mw32_hide_mouse_by_wheel)) 
    43814410        { 
    4382           dpyinfo->mouse_cursor_stat = -1; 
    4383           ShowCursor (FALSE); 
    4384  
    4385           hidden_by_wheel = 1; 
    4386  
    4387           if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) 
     4411          /* reset start point of measuring mouse movement */ 
     4412          lastpos.x = LOWORD (last_mouse_motion_message.lParam); 
     4413          lastpos.y = HIWORD (last_mouse_motion_message.lParam); 
     4414 
     4415          if (dpyinfo->mouse_cursor_stat == 0) 
    43884416            { 
    4389               clear_mouse_face (dpyinfo); 
    4390               dpyinfo->mouse_face_hidden = 1; 
     4417              dpyinfo->mouse_cursor_stat = -1; 
     4418              ShowCursor (FALSE); 
     4419 
     4420              insensitive_range = mw32_hide_mouse_stickiness; 
     4421              if (NUMBERP (mw32_hide_mouse_by_wheel)) 
     4422                insensitive_range = XINT (mw32_hide_mouse_by_wheel); 
     4423 
     4424              if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) 
     4425                { 
     4426                  clear_mouse_face (dpyinfo); 
     4427                  dpyinfo->mouse_face_hidden = 1; 
     4428                } 
     4429           
     4430              POST_THREAD_INFORM_MESSAGE (main_thread_id, 
     4431                                          WM_EMACS_HIDE_TOOLTIP, 
     4432                                          0, 0); 
    43914433            } 
    4392            
    4393           POST_THREAD_INFORM_MESSAGE (main_thread_id, 
    4394                                       WM_EMACS_HIDE_TOOLTIP, 
    4395                                       0, 0); 
    43964434        } 
    43974435      break; 
     
    68196857              doc: /* Position of a mouse button sent to emacs, when the w32 right button 
    68206858is changed.  */); 
    6821   DEFVAR_INT ("w32-hide-mouse-timeout", &mw32_hide_mouse_timeout, 
     6859  DEFVAR_INT ("w32-hide-mouse-stickiness", &mw32_hide_mouse_stickiness, 
     6860              doc: /* Insensitive range of mouse motion to restore cursor hidden by 
     6861`w32-hide-mouse-timeout' or `w32-hide-mouse-on-key' 
     6862or `w32-hide-mouse-by-wheel'. 
     6863Positive number means movement from where the cursor has been hidden, 
     6864and negative means movement between two successive WM_MOUSEMOVE messages. */); 
     6865  DEFVAR_LISP ("w32-hide-mouse-timeout", &mw32_hide_mouse_timeout, 
    68226866              doc: /* Mouse cursor will hide after some rest. (in milliseconds) 
    6823 Cursor will not hide if 0. (default) */); 
     6867Cursor will not hide if 0. (default) 
     6868If value is cons of two numbers, the car is timeout and the cdr is insensitive 
     6869range of mouse motion for restoring cursor which overrides 
     6870`w32-hide-mouse-stickiness'.*/); 
    68246871  DEFVAR_LISP ("w32-hide-mouse-by-wheel", &mw32_hide_mouse_by_wheel, 
    6825                doc: /* Non nil means mouse cursor will hide on mouse wheel rotation. */); 
    6826   DEFVAR_BOOL ("w32-hide-mouse-on-key", &mw32_hide_mouse_on_key, 
    6827                doc: /* Non nil means mouse cursor will hide on key input.  */); 
     6872               doc: /* Non nil means mouse cursor will hide on mouse wheel rotation. 
     6873Value of a number means insensitive range of mouse motion for restoring 
     6874cursor which overrides `w32-hide-mouse-stickiness'. */); 
     6875  DEFVAR_LISP ("w32-hide-mouse-on-key", &mw32_hide_mouse_on_key, 
     6876               doc: /* Non nil means mouse cursor will hide on key input. 
     6877Value of a number means insensitive range of mouse motion for restoring 
     6878cursor which overrides `w32-hide-mouse-stickiness'. */); 
    68286879 
    68296880 
     
    68356886 
    68366887 
    6837   mw32_hide_mouse_timeout = 0;    /* infinite */ 
    6838   mw32_hide_mouse_on_key = 0
     6888  mw32_hide_mouse_timeout = make_number(0);    /* infinite */ 
     6889  mw32_hide_mouse_on_key = Qnil
    68396890  mw32_hide_mouse_by_wheel = Qnil; 
    68406891  mw32_lbutton_to_emacs_button = 0;