/[crust]/crust/server/input-mouse.c
ViewVC logotype

Diff of /crust/server/input-mouse.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by jrydberg, Sun Sep 2 20:54:59 2001 UTC revision 1.4 by jrydberg, Mon Sep 17 12:38:52 2001 UTC
# Line 68  static struct layer *cursor_layer; Line 68  static struct layer *cursor_layer;
68  /* Surface that have focus right now.  */  /* Surface that have focus right now.  */
69  struct surface *surface_event_focus = 0;  struct surface *surface_event_focus = 0;
70    
71    /* Surface that have grabbed cursor.  */
72    struct surface *surface_event_cursor = 0;
73    
74  /* This is called from the mouse thread when there is some mouse  /* This is called from the mouse thread when there is some mouse
75     movement.  */     movement.  */
76  void  void
# Line 95  mouse_event_motion (int dx, int dy) Line 98  mouse_event_motion (int dx, int dy)
98    mouse_pos_x = mouse_pos_x + dx;    mouse_pos_x = mouse_pos_x + dx;
99    mouse_pos_y = mouse_pos_y - dy;    mouse_pos_y = mouse_pos_y - dy;
100    
101    /* Check if focus has changed.  Focus follows the mouse cursor.  */    /* If someone have grabbed the cursor we dispatch event to it.  */
102    new_focus = locate_surface_at_point (mouse_pos_x, mouse_pos_y);    if (surface_event_cursor)
   if (new_focus != surface_event_focus)  
103      {      {
104        if (surface_event_focus)        int px, py;
         responder_post_event_focus_leave (surface_event_focus);  
       if (new_focus)  
         {  
           int px = new_focus->layer->absolute_x + new_focus->x;  
           int py = new_focus->layer->absolute_y + new_focus->y;  
   
           responder_post_event_focus_enter (new_focus,  
                                             mouse_pos_x - px,  
                                             mouse_pos_y - py);  
         }  
105    
106        surface_event_focus = new_focus;        px = surface_event_cursor->layer->absolute_x + surface_event_cursor->x;
107        printf ("focus changed to %p\n", new_focus);        py = surface_event_cursor->layer->absolute_y + surface_event_cursor->y;
108        sent_focused = true;        
109          responder_post_event_mouse_moved (surface_event_cursor,
110                                            mouse_pos_x - px,
111                                            mouse_pos_y - py,
112                                            mouse_pos_x,
113                                            mouse_pos_y);
114      }      }
115      else
   if (surface_event_focus && !sent_focused)  
116      {      {
117        int px = surface_event_focus->layer->absolute_x + surface_event_focus->x;        /* Check if focus has changed.  Focus follows the mouse cursor.  */
118        int py = surface_event_focus->layer->absolute_y + surface_event_focus->y;        new_focus = locate_surface_at_point (mouse_pos_x, mouse_pos_y);
119          if (new_focus != surface_event_focus)
120        responder_post_event_mouse_moved (surface_event_focus,          {
121                                          mouse_pos_x - px,            if (surface_event_focus)
122                                          mouse_pos_y - py);              responder_post_event_focus_leave (surface_event_focus);
123              if (new_focus)
124                {
125                  int px = new_focus->layer->absolute_x + new_focus->x;
126                  int py = new_focus->layer->absolute_y + new_focus->y;
127                  
128                  responder_post_event_focus_enter (new_focus,
129                                                    mouse_pos_x - px,
130                                                    mouse_pos_y - py);
131                }
132              
133              surface_event_focus = new_focus;
134              printf ("focus changed to %p\n", new_focus);
135              sent_focused = true;
136            }
137          
138          if (surface_event_focus && !sent_focused)
139            {
140              int px = surface_event_focus->layer->absolute_x + surface_event_focus->x;
141              int py = surface_event_focus->layer->absolute_y + surface_event_focus->y;
142              
143              responder_post_event_mouse_moved (surface_event_focus,
144                                                mouse_pos_x - px,
145                                                mouse_pos_y - py,
146                                                mouse_pos_x,
147                                                mouse_pos_y);
148            }
149      }      }
150    
151    if (cursor_layer)    if (cursor_layer)
152      move_layer (cursor_layer, mouse_pos_x, mouse_pos_y);      move_layer (cursor_layer, mouse_pos_x, mouse_pos_y);
153    else    else
154      crust_log (LOGLEVEL_TOTAL, "no cursor layer\n");      crust_log (LOGLEVEL_TOTAL, "no cursor layer\n");
155    #if 0
156      if (surface_event_cursor)
157        {
158          move_layer (surface_event_cursor->layer,
159                      surface_event_cursor->layer->x + dx, surface_event_cursor->layer->y - dy);
160        }
161    #endif
162  }  }
163    
164  void  void
# Line 149  mouse_event_button (int button, bool dow Line 178  mouse_event_button (int button, bool dow
178          responder_post_event_mouse_down (surface_event_focus,          responder_post_event_mouse_down (surface_event_focus,
179                                           button,                                           button,
180                                           mouse_pos_x - px,                                           mouse_pos_x - px,
181                                           mouse_pos_y - py);                                           mouse_pos_y - py,
182                                             mouse_pos_x,
183                                             mouse_pos_y);
184        else        else
185          responder_post_event_mouse_up (surface_event_focus,          responder_post_event_mouse_up (surface_event_focus,
186                                         button,                                         button,
187                                         mouse_pos_x - px,                                         mouse_pos_x - px,
188                                         mouse_pos_y - py);                                         mouse_pos_y - py,
189                                           mouse_pos_x,
190                                           mouse_pos_y);
191      }      }
192  }  }
193    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26