[Scummvm-cvs-logs] CVS: scummvm/mac mac.cpp,1.7,1.8

Mutwin Kraus mutle at users.sourceforge.net
Mon Mar 18 08:36:02 CET 2002


Update of /cvsroot/scummvm/scummvm/mac
In directory usw-pr-cvs1:/tmp/cvs-serv30543/scummvm/mac

Modified Files:
	mac.cpp 
Log Message:
Updated the Event Handling and some other stuff. Should run better now.

Index: mac.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/mac/mac.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** mac.cpp	17 Mar 2002 15:10:18 -0000	1.7
--- mac.cpp	18 Mar 2002 16:34:57 -0000	1.8
***************
*** 153,157 ****
  	{ kEventClassMouse, kEventMouseMoved },
  	{ kEventClassKeyboard, kEventRawKeyDown },
! 	{ kEventClassCommand, kEventProcessCommand },
  	{ kEventClassWindow, kEventWindowClose }
  };
--- 153,163 ----
  	{ kEventClassMouse, kEventMouseMoved },
  	{ kEventClassKeyboard, kEventRawKeyDown },
! 	{ kEventClassCommand, kEventProcessCommand }
! };
! 
! const EventTypeSpec kWindowEvents[] =
! {
! 	{ kEventClassWindow, kEventWindowDrawContent },
! 	{ kEventClassWindow, kEventWindowHandleContentClick },
  	{ kEventClassWindow, kEventWindowClose }
  };
***************
*** 163,166 ****
--- 169,200 ----
  }
  
+ static pascal OSStatus WindowEventHandler( EventHandlerCallRef inCallRef, EventRef inEvent, void* userData )
+ {
+ 	OSStatus		result = eventNotHandledErr;
+ 	
+ 	if(GetEventClass(inEvent) == kEventClassWindow)
+ 	{
+ 		switch(GetEventKind(inEvent))
+ 		{
+ 			case kEventWindowDrawContent:
+ 				wm->writeToScreen();
+ 			break;
+ 			
+ 			case kEventWindowHandleContentClick:
+ 				//debug(1, "Sending MouseDown");
+ 				if(CommandKeyDown())
+ 					wm->_scumm->_rightBtnPressed |= msClicked|msDown;
+ 				else
+ 					wm->_scumm->_leftBtnPressed |= msClicked|msDown;
+ 			break;
+ 			
+ 			case kEventWindowClose:
+ 				Quit();
+ 			break;
+ 		}
+ 	}
+ 	return result;
+ }
+ 
  static pascal OSStatus EventHandler( EventHandlerCallRef inCallRef, EventRef inEvent, void* userData )
  {
***************
*** 174,183 ****
  	switch(GetEventClass(inEvent))
  	{
- 		case kEventClassWindow:
- 			WindowRef	theWin;
- 			GetEventParameter( inEvent, kEventParamDirectObject, typeWindowRef, NULL,
- 				sizeof( WindowRef ), NULL, &theWin );
- 			if(theWin == wm->wPtr)
- 				Quit();
  		case kEventClassCommand:
  			switch(command.commandID)
--- 208,211 ----
***************
*** 225,264 ****
  		case kEventClassMouse:
  		switch(GetEventKind(inEvent))
! 		{
! 			
  			case kEventMouseDown:
! 				WindowPtr window;
! 				int part;
  				
! 				GetEventParameter(inEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mouse);
! 				part = FindWindow(mouse, &window);
! 				switch(part)
  				{
! 					case inContent:
! 						if((window != FrontWindow() && window == wm->wPtr))
! 						{
! 							SelectWindow(window);
! 							BringToFront(window);
! 						}
! 						if(window == wm->wPtr)
! 						{
! 							if(CommandKeyDown())
! 								wm->_scumm->_rightBtnPressed |= msClicked|msDown;
! 							else
! 								wm->_scumm->_leftBtnPressed |= msClicked|msDown;
! 						}
! 					break;
! 					
! 					case inDrag:
! 						BitMap	qdscreenbits;
! 						
! 						GetQDGlobalsScreenBits(&qdscreenbits);
! 						DragWindow(window, mouse, &qdscreenbits.bounds);
! 					break;
! 					
! 					case inGoAway:
! 						if(TrackGoAway(window, mouse) && window == wm->wPtr)
! 							Quit();
! 					break;
  				}
  			break;
--- 253,265 ----
  		case kEventClassMouse:
  		switch(GetEventKind(inEvent))
! 		{			
  			case kEventMouseDown:
! 				WindowRef theWin;
  				
! 				GetEventParameter(inEvent, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef),
! 					NULL, &theWin);
! 				if(theWin != FrontWindow())
  				{
! 					ActivateWindow(theWin, true);
  				}
  			break;
***************
*** 269,290 ****
  			break;
  			
! 			case kEventMouseMoved:
! 				Point mouse2;
! 				
! 				GetEventParameter(inEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mouse2);
  				
! 				CGrafPtr oldPort;
! 				GetPort(&oldPort);
! 				SetPortWindowPort(wm->wPtr);
! 				Rect wRect;
! 				GetPortBounds(GetWindowPort(wm->wPtr), &wRect);
! 				if(PtInRect(mouse2, &wRect))
  				{
! 					GlobalToLocal(&mouse2);
  					
! 					wm->_scumm->mouse.x = mouse2.h/wm->scale;
! 					wm->_scumm->mouse.y = mouse2.v/wm->scale+25;
  				}
- 				SetPort(oldPort);
  			break;
  		}
--- 270,290 ----
  			break;
  			
! 			case kEventMouseMoved:				
! 				GetEventParameter(inEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mouse);
! 				Rect winRect;
  				
! 				GetWindowBounds(wm->wPtr, kWindowContentRgn, &winRect);
! 				if(PtInRect(mouse, &winRect))
  				{
! 					CGrafPtr oldPort;
  					
! 					GetPort(&oldPort);
! 					SetPortWindowPort(wm->wPtr);
! 					GlobalToLocal(&mouse);
! 					scumm.mouse.x = mouse.h/wm->scale;
! 					scumm.mouse.y = mouse.v/wm->scale;
! 					
! 					//debug(1, "Mouse X:%i Y:%i", scumm.mouse.x, scumm.mouse.y);
  				}
  			break;
  		}
***************
*** 350,355 ****
  	
  	SetRect(&rectWin, 0, 0, DEST_WIDTH, DEST_HEIGHT);
! 	UInt32 WinAttrib = (kWindowCloseBoxAttribute | kWindowFullZoomAttribute |
! 				kWindowCollapseBoxAttribute | kWindowInWindowMenuAttribute);
  	
  	if(noErr != CreateNewWindow(kDocumentWindowClass, WinAttrib, &rectWin, &wPtr))
--- 350,355 ----
  	
  	SetRect(&rectWin, 0, 0, DEST_WIDTH, DEST_HEIGHT);
! 	UInt32 WinAttrib = (kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute |
! 				kWindowInWindowMenuAttribute | kWindowStandardHandlerAttribute);
  	
  	if(noErr != CreateNewWindow(kDocumentWindowClass, WinAttrib, &rectWin, &wPtr))
***************
*** 368,376 ****
  	SetRect(&dstRect, 0, 0, DEST_WIDTH, DEST_HEIGHT);
  	SetRect(&srcRect, 0, 0, SRC_WIDTH, SRC_HEIGHT);	
- 	
- 	//InstallStandardEventHandler(GetWindowEventTarget(wPtr));
  
  	InstallApplicationEventHandler(NewEventHandlerUPP(EventHandler),
  				GetEventTypeCount(kCmdEvents), kCmdEvents, 0, NULL);
  	
  	OSStatus err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(QuitEventHandler), 0L, false);
--- 368,377 ----
  	SetRect(&dstRect, 0, 0, DEST_WIDTH, DEST_HEIGHT);
  	SetRect(&srcRect, 0, 0, SRC_WIDTH, SRC_HEIGHT);	
  
  	InstallApplicationEventHandler(NewEventHandlerUPP(EventHandler),
  				GetEventTypeCount(kCmdEvents), kCmdEvents, 0, NULL);
+ 	InstallStandardEventHandler(GetWindowEventTarget(wPtr));
+ 	InstallWindowEventHandler(wPtr, NewEventHandlerUPP(WindowEventHandler),
+ 				GetEventTypeCount(kWindowEvents), kWindowEvents, 0, NULL);
  	
  	OSStatus err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(QuitEventHandler), 0L, false);
***************
*** 379,382 ****
--- 380,385 ----
  	InstallEventLoopTimer(GetCurrentEventLoop(), 0, 0, NewEventLoopTimerUPP(DoGameLoop),
  						NULL, &theTimer);
+ 	
+ 	NewGWorldFromPtr(&screenBuf, 8, &srcRect, pal, nil, 0, (char *)_vgabuf, SRC_WIDTH);
  }
  
***************
*** 419,423 ****
  void WndMan::writeToScreen()
  {
! 	NewGWorldFromPtr(&screenBuf, 8, &srcRect, pal, nil, 0, (char *)_vgabuf, SRC_WIDTH);
  	CopyBits(GetPortBitMapForCopyBits(screenBuf),
  			GetPortBitMapForCopyBits(GetWindowPort(wPtr)), 
--- 422,426 ----
  void WndMan::writeToScreen()
  {
! 	//NewGWorldFromPtr(&screenBuf, 8, &srcRect, pal, nil, 0, (char *)_vgabuf, SRC_WIDTH);
  	CopyBits(GetPortBitMapForCopyBits(screenBuf),
  			GetPortBitMapForCopyBits(GetWindowPort(wPtr)), 
***************
*** 455,458 ****
--- 458,462 ----
  		(*pal)->ctTable[i].rgb.blue = ctab[2]<<8;
  	}
+ 	NewGWorldFromPtr(&screenBuf, 8, &srcRect, pal, nil, 0, (char *)_vgabuf, SRC_WIDTH);
  }
  
***************
*** 911,915 ****
  /* FIXME: CD Music Stubs */
  void cd_playtrack(int track, int offset, int delay) {;}
! void cd_play(int track, int num_loops, int start_frame) {;}
  void cd_stop() {;}
  int cd_is_running() {return 0;}
--- 915,919 ----
  /* FIXME: CD Music Stubs */
  void cd_playtrack(int track, int offset, int delay) {;}
! void cd_play(int track, int num_loops, int start_frame, int end_frame) {;}
  void cd_stop() {;}
  int cd_is_running() {return 0;}





More information about the Scummvm-git-logs mailing list