/[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.1.1.1 by jrydberg, Tue Aug 21 21:41:56 2001 UTC revision 1.2 by jrydberg, Sat Aug 25 13:39:00 2001 UTC
# Line 25  Line 25 
25  #include "thost.h"  #include "thost.h"
26    
27  #include <stdbool.h>  #include <stdbool.h>
28    #include <stdio.h>
29  #include <error.h>  #include <error.h>
30    
31  #include "std-types.h"  #include "std-types.h"
# Line 64  bool mouse_visible_p = false; Line 65  bool mouse_visible_p = false;
65  static struct surface *stock_cursor_surface;  static struct surface *stock_cursor_surface;
66  static struct layer *cursor_layer;  static struct layer *cursor_layer;
67    
68    /* Surface that have focus right now.  */
69    struct surface *surface_event_focus = 0;
70    
71  /* This is called from the mouse thread when there is some mouse  /* This is called from the mouse thread when there is some mouse
72     movement.  */     movement.  */
73  void  void
74  mouse_event_motion (int dx, int dy)  mouse_event_motion (int dx, int dy)
75  {  {
76    unsigned int new_x = mouse_pos_x, new_y = mouse_pos_y;    unsigned int new_x = mouse_pos_x, new_y = mouse_pos_y;
77      struct surface *new_focus;
78    
79    if (mouse_pos_x + dx < 0)    if (mouse_pos_x + dx < 0)
80      dx = -mouse_pos_x;      dx = -mouse_pos_x;
# Line 83  mouse_event_motion (int dx, int dy) Line 88  mouse_event_motion (int dx, int dy)
88    if (mouse_pos_y - dy >= ((crust_current_mode->vdisplay) - 1))    if (mouse_pos_y - dy >= ((crust_current_mode->vdisplay) - 1))
89      dy = -((crust_current_mode->vdisplay - 1) - mouse_pos_y);      dy = -((crust_current_mode->vdisplay - 1) - mouse_pos_y);
90    
91    crust_log (LOGLEVEL_TOTAL, "move mouse to (%d,%d): %x\n", new_x, new_y, (int) cursor_layer);    crust_log (LOGLEVEL_TOTAL, "move mouse to (%d,%d): %x\n",
92                 new_x, new_y, (int) cursor_layer);
93    
94    mouse_pos_x = mouse_pos_x + dx;    mouse_pos_x = mouse_pos_x + dx;
95    mouse_pos_y = mouse_pos_y - dy;    mouse_pos_y = mouse_pos_y - dy;
96    
97      /* Check if focus has changed.  Focus follows the mouse cursor.  */
98      new_focus = locate_surface_at_point (mouse_pos_x, mouse_pos_y);
99      if (new_focus != surface_event_focus)
100        {
101          if (surface_event_focus)
102            responder_post_event_focus_leave (surface_event_focus);
103          if (new_focus)
104            responder_post_event_focus_enter (new_focus);
105    
106          surface_event_focus = new_focus;
107          printf ("focus changed to %p\n", new_focus);
108        }
109    
110      if (surface_event_focus)
111        {
112          int px = surface_event_focus->layer->absolute_x + surface_event_focus->x;
113          int py = surface_event_focus->layer->absolute_y + surface_event_focus->y;
114    
115          responder_post_event_mouse_moved (surface_event_focus,
116                                            mouse_pos_x - px,
117                                            mouse_pos_y - py);
118        }
119    
120    if (cursor_layer)    if (cursor_layer)
121      move_layer (cursor_layer, mouse_pos_x, mouse_pos_y);      move_layer (cursor_layer, mouse_pos_x, mouse_pos_y);
122    else    else

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

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