diff src/video/maccommon/SDL_macevents.c @ 155:2d162219f433

Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST) From: Darrell Walisser <dwaliss1@purdue.edu> Subject: Patch for video bugs + Max's additions I've attached a patch for today's CVS that includes Max's virtual mouse button fix as well as some other changes: -building mode list correctly now (had duplicate entries, was unsorted) -switching modes correctly now (wasn't destroying previous mode) -releasing memory correctly in event loop
author Sam Lantinga <slouken@libsdl.org>
date Sun, 19 Aug 2001 23:57:39 +0000
parents ee3bb7cd06b5
children e92aa316c517
line wrap: on
line diff
--- a/src/video/maccommon/SDL_macevents.c	Sat Aug 18 22:24:19 2001 +0000
+++ b/src/video/maccommon/SDL_macevents.c	Sun Aug 19 23:57:39 2001 +0000
@@ -107,6 +107,7 @@
 /* The main MacOS event handler */
 static int Mac_HandleEvents(_THIS, int wait4it)
 {
+	static int mouse_button = 1;
 	int i;
 	EventRecord event;
 
@@ -148,7 +149,7 @@
 	/* for some reason, event.where isn't set ? */
 	GetGlobalMouse ( &event.where );
 #endif
-    
+
 	/* Check for mouse motion */
 	if ( (event.where.h != last_where.h) ||
 	     (event.where.v != last_where.v) ) {
@@ -282,16 +283,14 @@
 			myGlobalToLocal(this, &event.where);
 			/* Treat command-click as right mouse button */
 			if ( event.modifiers & optionKey ) {
-			    SDL_PrivateMouseButton(SDL_PRESSED,
-					2,event.where.h,event.where.v);
+				mouse_button = 2;
+			} else if ( event.modifiers & cmdKey ) {
+				mouse_button = 3;
+			} else {
+				mouse_button = 1;
 			}
-			else if ( event.modifiers & cmdKey ) {
-			    SDL_PrivateMouseButton(SDL_PRESSED,
-					3,event.where.h,event.where.v);
-			} else {
-			    SDL_PrivateMouseButton(SDL_PRESSED,
-					1,event.where.h,event.where.v);
-			}
+			SDL_PrivateMouseButton(SDL_PRESSED,
+				mouse_button, event.where.h, event.where.v);
 			break;
 		  case inGrow: {
 			int newSize;
@@ -336,7 +335,7 @@
 			if ( TrackBox (win, event.where, area )) {
 				if ( IsWindowCollapsable(win) ) {
 					CollapseWindow (win, !IsWindowCollapsed(win));
-					// There should be something done like in inGrow case, but...
+					/* There should be something done like in inGrow case, but... */
 				}
 			}
 			break;
@@ -355,18 +354,14 @@
 	  break;
 	  case mouseUp: {
 		myGlobalToLocal(this, &event.where);
-		/* Treat command-click as right mouse button */
-		if ( event.modifiers & cmdKey ) {
-		    SDL_PrivateMouseButton(SDL_RELEASED,
-				3, event.where.h, event.where.v);
-		}
-		else if ( event.modifiers & optionKey ) {
-		    SDL_PrivateMouseButton(SDL_RELEASED,
-				2,event.where.h,event.where.v);
-		} else {
-		    SDL_PrivateMouseButton(SDL_RELEASED,
-				1, event.where.h, event.where.v);
-		}
+		/* Release the mouse button we simulated in the last press.
+		   The drawback of this methos is we cannot press more than
+		   one button. However, this doesn't matter, since there is
+		   only a single logical mouse button, even if you have a
+		   multi-button mouse, this doesn't matter at all.
+		 */
+		SDL_PrivateMouseButton(SDL_RELEASED,
+			mouse_button, event.where.h, event.where.v);
 	  }
 	  break;
 #if 0 /* Handled above the switch statement */