~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/X11/mousestate.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /src/X11/mousestate.c (Architecture i386) and /src/X11/mousestate.c (Architecture sparc)


  1 /**@(#)                                             1 /**@(#)
  2 **/                                                 2 **/
  3 /**                                                 3 /**
  4 tv_screen_mousestate.c:                             4 tv_screen_mousestate.c:
  5 Simple description of current mouse event.          5 Simple description of current mouse event.
  6 **/                                                 6 **/
  7                                                     7 
  8 #include <stdio.h>                                  8 #include <stdio.h>
  9 #include <tina/sys.h>                               9 #include <tina/sys.h>
 10 #include <tina/sysfuncs.h>                         10 #include <tina/sysfuncs.h>
 11 #include <tina/math.h>                             11 #include <tina/math.h>
 12 #include <tina/tv.h>                               12 #include <tina/tv.h>
 13 #include <tina/tv_screen.h>                        13 #include <tina/tv_screen.h>
 14                                                    14 
 15 void    format_mousestate(int state)               15 void    format_mousestate(int state)
 16 {                                                  16 {
 17     switch (state)                                 17     switch (state)
 18     {                                              18     {
 19         case LEFT_DOWN:                            19         case LEFT_DOWN:
 20         format("LEFT_DOWN\n");                     20         format("LEFT_DOWN\n");
 21         break;                                     21         break;
 22     case LEFT_DRAG:                                22     case LEFT_DRAG:
 23         format("LEFT_DRAG\n");                     23         format("LEFT_DRAG\n");
 24         break;                                     24         break;
 25     case LEFT_UP:                                  25     case LEFT_UP:
 26         format("LEFT_UP\n");                       26         format("LEFT_UP\n");
 27         break;                                     27         break;
 28     case MIDDLE_DOWN:                              28     case MIDDLE_DOWN:
 29         format("MIDDLE_DOWN\n");                   29         format("MIDDLE_DOWN\n");
 30         break;                                     30         break;
 31     case MIDDLE_DRAG:                              31     case MIDDLE_DRAG:
 32         format("MIDDLE_DRAG\n");                   32         format("MIDDLE_DRAG\n");
 33         break;                                     33         break;
 34     case MIDDLE_UP:                                34     case MIDDLE_UP:
 35         format("MIDDLE_UP\n");                     35         format("MIDDLE_UP\n");
 36         break;                                     36         break;
 37     case RIGHT_DOWN:                               37     case RIGHT_DOWN:
 38         format("RIGHT_DOWN\n");                    38         format("RIGHT_DOWN\n");
 39         break;                                     39         break;
 40     case RIGHT_DRAG:                               40     case RIGHT_DRAG:
 41         format("RIGHT_DRAG\n");                    41         format("RIGHT_DRAG\n");
 42         break;                                     42         break;
 43     case RIGHT_UP:                                 43     case RIGHT_UP:
 44         format("RIGHT_UP\n");                      44         format("RIGHT_UP\n");
 45         break;                                     45         break;
 46     case WAIT_STATE:                               46     case WAIT_STATE:
 47         format("WAIT_STATE\n");                    47         format("WAIT_STATE\n");
 48         break;                                     48         break;
 49     case BAD_STATE:                                49     case BAD_STATE:
 50         format("BAD_STATE\n");                     50         format("BAD_STATE\n");
 51         break;                                     51         break;
 52     default:                                       52     default:
 53         format("STRANGE_STATE\n");                 53         format("STRANGE_STATE\n");
 54         break;                                     54         break;
 55     }                                              55     }
 56 }                                                  56 }
 57                                                    57 
 58 int     mouse_get_state(XEvent * event, Ipos *     58 int     mouse_get_state(XEvent * event, Ipos * pos)
 59 {                                                  59 {
 60     static int mouse_state = BAD_STATE;            60     static int mouse_state = BAD_STATE;
 61                                                    61 
 62     switch (event->type)                           62     switch (event->type)
 63     {                                              63     {
 64     case ButtonPress:                              64     case ButtonPress:
 65         switch (event->xbutton.button)             65         switch (event->xbutton.button)
 66         {                                          66         {
 67         case Button1:                              67         case Button1:
 68             mouse_state = LEFT_DOWN;               68             mouse_state = LEFT_DOWN;
 69             break;                                 69             break;
 70         case Button2:                              70         case Button2:
 71             mouse_state = MIDDLE_DOWN;             71             mouse_state = MIDDLE_DOWN;
 72             break;                                 72             break;
 73         case Button3:                              73         case Button3:
 74             mouse_state = RIGHT_DOWN;              74             mouse_state = RIGHT_DOWN;
 75             break;                                 75             break;
 76         default:                                   76         default:
 77             return (BAD_STATE);                    77             return (BAD_STATE);
 78         }                                          78         }
 79         break;                                     79         break;
 80     case MotionNotify:                             80     case MotionNotify:
 81                                                    81 
 82         /* Compress MotionNotify events */         82         /* Compress MotionNotify events */
 83         {                                          83         {
 84             Display *display = event->xmotion.     84             Display *display = event->xmotion.display;
 85             XEvent  ahead;                         85             XEvent  ahead;
 86                                                    86 
 87             while (XEventsQueued(display, Queu     87             while (XEventsQueued(display, QueuedAfterReading) > 0 &&
 88             (XPeekEvent(display, &ahead), ahea     88             (XPeekEvent(display, &ahead), ahead.type == MotionNotify))
 89             {                                      89             {
 90                 XNextEvent(display, event);        90                 XNextEvent(display, event);
 91             }                                      91             }
 92         }                                          92         }
 93                                                    93 
 94         switch (mouse_state)                       94         switch (mouse_state)
 95         {                                          95         {
 96                                                    96 
 97         case LEFT_DOWN:                            97         case LEFT_DOWN:
 98         case LEFT_DRAG:                            98         case LEFT_DRAG:
 99             mouse_state = LEFT_DRAG;               99             mouse_state = LEFT_DRAG;
100             break;                                100             break;
101         case MIDDLE_DOWN:                         101         case MIDDLE_DOWN:
102         case MIDDLE_DRAG:                         102         case MIDDLE_DRAG:
103             mouse_state = MIDDLE_DRAG;            103             mouse_state = MIDDLE_DRAG;
104             break;                                104             break;
105         case RIGHT_DOWN:                          105         case RIGHT_DOWN:
106         case RIGHT_DRAG:                          106         case RIGHT_DRAG:
107             mouse_state = RIGHT_DRAG;             107             mouse_state = RIGHT_DRAG;
108             break;                                108             break;
109         default:                                  109         default:
110             return (BAD_STATE);                   110             return (BAD_STATE);
111         }                                         111         }
112         break;                                    112         break;
113     case ButtonRelease:                           113     case ButtonRelease:
114         switch (event->xbutton.button)            114         switch (event->xbutton.button)
115         {                                         115         {
116         case Button1:                             116         case Button1:
117             mouse_state = LEFT_UP;                117             mouse_state = LEFT_UP;
118             break;                                118             break;
119         case Button2:                             119         case Button2:
120             mouse_state = MIDDLE_UP;              120             mouse_state = MIDDLE_UP;
121             break;                                121             break;
122         case Button3:                             122         case Button3:
123             mouse_state = RIGHT_UP;               123             mouse_state = RIGHT_UP;
124             break;                                124             break;
125         default:                                  125         default:
126             return (BAD_STATE);                   126             return (BAD_STATE);
127         }                                         127         }
128         break;                                    128         break;
129     default:                                      129     default:
130         return (BAD_STATE);                       130         return (BAD_STATE);
131     }                                             131     }
132                                                   132 
133     switch (event->type)                          133     switch (event->type)
134     {                                             134     {
135     case ButtonPress:                             135     case ButtonPress:
136     case ButtonRelease:                           136     case ButtonRelease:
137         pos->x = event->xbutton.x;                137         pos->x = event->xbutton.x;
138         pos->y = event->xbutton.y;                138         pos->y = event->xbutton.y;
139         break;                                    139         break;
140     case MotionNotify:                            140     case MotionNotify:
141         pos->x = event->xmotion.x;                141         pos->x = event->xmotion.x;
142         pos->y = event->xmotion.y;                142         pos->y = event->xmotion.y;
143         break;                                    143         break;
144     }                                             144     }
145                                                   145 
146     return (mouse_state);                         146     return (mouse_state);
147 }                                                 147 }
148                                                   148 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.