began to factor out code to move to darwinEvents.c
This commit is contained in:
		
							parent
							
								
									537dc5ecde
								
							
						
					
					
						commit
						fe7b8f4237
					
				|  | @ -855,21 +855,58 @@ convert_flags (unsigned int nsflags) { | ||||||
|     return xflags; |     return xflags; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /* Sends a null byte down darwinEventWriteFD, which will cause the | ||||||
|  |    Dispatch() event loop to check out event queue */ | ||||||
|  | void DarwinPokeEQ(void) { | ||||||
|  |   char nullbyte=0; | ||||||
|  |   input_check_flag++; | ||||||
|  |   //  <daniels> bushing: oh, i ... er ... christ. | ||||||
|  |   write(darwinEventWriteFD, &nullbyte, 1); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y) { | ||||||
|  |   int i; | ||||||
|  |   int valuators[2] = {pointer_x, pointer_y}; | ||||||
|  |   int num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button,  | ||||||
|  | 				    POINTER_ABSOLUTE, 0, 2, valuators); | ||||||
|  |        | ||||||
|  |   for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]); | ||||||
|  |   DarwinPokeEQ(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void DarwinSendKeyboardEvents(int ev_type, int keycode) { | ||||||
|  |   int i; | ||||||
|  |   int num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE); | ||||||
|  |   for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]); | ||||||
|  |   DarwinPokeEQ(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */ | ||||||
|  | void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y) { | ||||||
|  |   int i; | ||||||
|  |   int ev_button = count > 0.0f ? 4 : 5; | ||||||
|  |   int valuators[2] = {pointer_x, pointer_y}; | ||||||
|  | 
 | ||||||
|  |   for (count = fabs(count); count > 0.0; count = count - 1.0f) { | ||||||
|  |     int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button,  | ||||||
|  | 				      POINTER_ABSOLUTE, 0, 2, valuators); | ||||||
|  |     for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]); | ||||||
|  |     num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button,  | ||||||
|  | 				      POINTER_ABSOLUTE, 0, 2, valuators); | ||||||
|  |     for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]); | ||||||
|  |   } | ||||||
|  |   DarwinPokeEQ(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // This code should probably be merged with that in XDarwin's XServer.m - BB | // This code should probably be merged with that in XDarwin's XServer.m - BB | ||||||
| static void send_nsevent (NSEventType type, NSEvent *e) { | static void send_nsevent (NSEventType type, NSEvent *e) { | ||||||
|     static unsigned int button_state = 0; |   //    static unsigned int button_state = 0; | ||||||
|     NSRect screen; |     NSRect screen; | ||||||
|     NSPoint location; |     NSPoint location; | ||||||
|     NSWindow *window; |     NSWindow *window; | ||||||
|     int pointer_x, pointer_y, ev_button, ev_type;  |     int pointer_x, pointer_y, ev_button, ev_type;  | ||||||
|     int num_events=0, i=0, state; |     //    int num_events=0, i=0, state; | ||||||
|     int valuators[2]; |  | ||||||
|     float count; |  | ||||||
|     xEvent xe; |     xEvent xe; | ||||||
|     char nullbyte=0; |  | ||||||
| 
 |  | ||||||
|     bzero(&xe, sizeof(xe)); |  | ||||||
|     input_check_flag++; |  | ||||||
| 	 | 	 | ||||||
|     /* convert location to global top-left coordinates */ |     /* convert location to global top-left coordinates */ | ||||||
|     location = [e locationInWindow]; |     location = [e locationInWindow]; | ||||||
|  | @ -886,11 +923,8 @@ static void send_nsevent (NSEventType type, NSEvent *e) { | ||||||
|       pointer_y = (screen.origin.y + screen.size.height) - location.y; |       pointer_y = (screen.origin.y + screen.size.height) - location.y; | ||||||
|     } |     } | ||||||
|      |      | ||||||
| //    ErrorF("send_nsevent: type=%d pointer=(%d,%d)\n", type, pointer_x, pointer_y); |     pointer_y -= aquaMenuBarHeight; | ||||||
|      |     //    state = convert_flags ([e modifierFlags]); | ||||||
|     valuators[0] = pointer_x; |  | ||||||
|     valuators[1] = pointer_y - aquaMenuBarHeight; |  | ||||||
|     state = convert_flags ([e modifierFlags]); |  | ||||||
|      |      | ||||||
|     switch (type) { |     switch (type) { | ||||||
|     case NSLeftMouseDown:    ev_button=1; ev_type=ButtonPress; goto handle_mouse; |     case NSLeftMouseDown:    ev_button=1; ev_type=ButtonPress; goto handle_mouse; | ||||||
|  | @ -905,50 +939,34 @@ static void send_nsevent (NSEventType type, NSEvent *e) { | ||||||
|     case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse; |     case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse; | ||||||
|     handle_mouse: |     handle_mouse: | ||||||
|        |        | ||||||
|       if(ev_type==ButtonPress) { |       /* I'm not sure the below code is necessary or useful (-bb) | ||||||
|  | 	if(ev_type==ButtonPress) { | ||||||
| 	if (!quartzProcs->IsX11Window([e window], [e windowNumber])) { | 	if (!quartzProcs->IsX11Window([e window], [e windowNumber])) { | ||||||
| 	  fprintf(stderr, "Dropping event because it's not a window\n"); | 	  fprintf(stderr, "Dropping event because it's not a window\n"); | ||||||
| 	  break; | 	  break; | ||||||
| 	} | 	} | ||||||
| 	button_state |= (1 << ev_button); | 	button_state |= (1 << ev_button); | ||||||
|  | 	DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y); | ||||||
|       } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break; |       } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break; | ||||||
|        |       */ | ||||||
|       num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button,  |       DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y); | ||||||
| 				    POINTER_ABSOLUTE, 0, 2, valuators); |  | ||||||
|        |  | ||||||
|       for(i=0; i<num_events; i++) |  | ||||||
| 	mieqEnqueue (darwinPointer,&darwinEvents[i]); |  | ||||||
|       break; |       break; | ||||||
|     case NSScrollWheel:  |     case NSScrollWheel:  | ||||||
|       count = [e deltaY]; |       DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y); | ||||||
|       ev_button = count > 0.0f ? 4 : 5; |  | ||||||
|       for (count = fabs(count); count > 0.0; count = count - 1.0f) { |  | ||||||
| 	num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button,  |  | ||||||
| 				      POINTER_ABSOLUTE, 0, 2, valuators); |  | ||||||
| 	for(i=0; i<num_events; i++)  |  | ||||||
| 	  mieqEnqueue(darwinPointer,&darwinEvents[i]); |  | ||||||
| 	num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button,  |  | ||||||
| 				      POINTER_ABSOLUTE, 0, 2, valuators); |  | ||||||
| 	for(i=0; i<num_events; i++) |  | ||||||
| 	  mieqEnqueue(darwinPointer,&darwinEvents[i]); |  | ||||||
|       } |  | ||||||
|       break; |       break; | ||||||
|        |        | ||||||
|     case NSKeyDown:  // do we need to translate these keyCodes? |     case NSKeyDown:  // do we need to translate these keyCodes? | ||||||
|     case NSKeyUp: |     case NSKeyUp: | ||||||
|       num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard,  |       DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]); | ||||||
| 				     (type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]); |  | ||||||
|       for(i=0; i<num_events; i++)  |  | ||||||
| 	mieqEnqueue(darwinKeyboard,&darwinEvents[i]); |  | ||||||
|       break; |       break; | ||||||
| 
 | 
 | ||||||
|     case NSFlagsChanged: |     case NSFlagsChanged: | ||||||
|  |       bzero(&xe, sizeof(xe)); | ||||||
|       xe.u.u.type = kXDarwinUpdateModifiers; |       xe.u.u.type = kXDarwinUpdateModifiers; | ||||||
|       xe.u.clientMessage.u.l.longs0 = [e modifierFlags]; |       xe.u.clientMessage.u.l.longs0 = [e modifierFlags]; | ||||||
|       DarwinEQEnqueue (&xe); |       DarwinEQEnqueue (&xe); | ||||||
|  |       DarwinPokeEQ(); | ||||||
|       break; |       break; | ||||||
|     default: break; /* for gcc */ |     default: break; /* for gcc */ | ||||||
|     }	 |     }	 | ||||||
|     //  <daniels> bushing: oh, i ... er ... christ. |  | ||||||
|     write(darwinEventWriteFD, &nullbyte, 1); |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -58,6 +58,10 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr); | ||||||
| void DarwinEQEnqueue(const xEvent *e); | void DarwinEQEnqueue(const xEvent *e); | ||||||
| void DarwinEQPointerPost(xEvent *e); | void DarwinEQPointerPost(xEvent *e); | ||||||
| void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX); | void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX); | ||||||
|  | void DarwinPokeEQ(void); | ||||||
|  | void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y); | ||||||
|  | void DarwinSendKeyboardEvents(int ev_type, int keycode); | ||||||
|  | void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y); | ||||||
| 
 | 
 | ||||||
| // From darwinKeyboard.c
 | // From darwinKeyboard.c
 | ||||||
| int DarwinModifierNXKeyToNXKeycode(int key, int side); | int DarwinModifierNXKeyToNXKeycode(int key, int side); | ||||||
|  |  | ||||||
|  | @ -269,7 +269,7 @@ void ProcessInputEvents(void) { | ||||||
|     static int darwinFakeMouseButtonMask = 0; |     static int darwinFakeMouseButtonMask = 0; | ||||||
|     input_check_flag=0; |     input_check_flag=0; | ||||||
| 
 | 
 | ||||||
|     ErrorF("calling mieqProcessInputEvents\n"); |     //    ErrorF("calling mieqProcessInputEvents\n");
 | ||||||
|     mieqProcessInputEvents(); |     mieqProcessInputEvents(); | ||||||
| 
 | 
 | ||||||
|     // Empty the signaling pipe
 |     // Empty the signaling pipe
 | ||||||
|  | @ -292,12 +292,12 @@ void ProcessInputEvents(void) { | ||||||
|         xe.u.keyButtonPointer.rootY -= darwinMainScreenY + |         xe.u.keyButtonPointer.rootY -= darwinMainScreenY + | ||||||
|                 dixScreenOrigins[miPointerCurrentScreen()->myNum].y; |                 dixScreenOrigins[miPointerCurrentScreen()->myNum].y; | ||||||
| 	 | 	 | ||||||
| 	ErrorF("old rootX = (%d,%d) darwinMainScreen = (%d,%d) dixScreenOrigins[%d]=(%d,%d)\n", | 	/*	ErrorF("old rootX = (%d,%d) darwinMainScreen = (%d,%d) dixScreenOrigins[%d]=(%d,%d)\n",
 | ||||||
| 	       xe.u.keyButtonPointer.rootX, xe.u.keyButtonPointer.rootY, | 	       xe.u.keyButtonPointer.rootX, xe.u.keyButtonPointer.rootY, | ||||||
| 	       darwinMainScreenX, darwinMainScreenY, | 	       darwinMainScreenX, darwinMainScreenY, | ||||||
| 	       miPointerCurrentScreen()->myNum, | 	       miPointerCurrentScreen()->myNum, | ||||||
| 	       dixScreenOrigins[miPointerCurrentScreen()->myNum].x, | 	       dixScreenOrigins[miPointerCurrentScreen()->myNum].x, | ||||||
| 	       dixScreenOrigins[miPointerCurrentScreen()->myNum].y); | 	       dixScreenOrigins[miPointerCurrentScreen()->myNum].y); */ | ||||||
| 
 | 
 | ||||||
| 	//Assumption - screen switching can only occur on motion events
 | 	//Assumption - screen switching can only occur on motion events
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue