if (dragging) gwin->drop_dragged(event.button.x >> scale,
bool click_handled = false; if (dragging) { click_handled = gwin->drop_dragged(event.button.x >> scale,
static void Handle_event	(	SDL_Event& event	)	{					// For detecting double-clicks.	static unsigned long last_b1_click = 0;	//cout << "Event " << (int) event.type << " received"<<endl;	switch (event.type)		{	case SDL_MOUSEBUTTONDOWN:		if (gwin->get_mode() != Game_window::normal &&		    gwin->get_mode() != Game_window::gump)			break;		if (event.button.button == 1)			{			dragging = gwin->start_dragging(					event.button.x >> scale,					event.button.y >> scale);			dragged = 0;			}					// Move sprite toward mouse					//  when right button pressed.		if (event.button.button == 3 && 		    gwin->get_mode() == Game_window::normal)			{		// Try removing old queue entry.			gwin->get_tqueue()->remove(gwin->get_main_actor());			gwin->start_actor(event.button.x >> scale, 				event.button.y >> scale, avatar_speed);			}		break;	case SDL_MOUSEBUTTONUP:		if (event.button.button == 3)			{#if 0			if (gwin->get_mode() != Game_window::normal &&			    gwin->get_mode() != Game_window::gump)				break;#endif			gwin->stop_actor();			}		else if (event.button.button == 1)			{			unsigned long curtime = SDL_GetTicks();			if (dragging)				gwin->drop_dragged(event.button.x >> scale, 					event.button.y >> scale, dragged);					// Last click within .5 secs?			if (curtime - last_b1_click < 500)				{				dragging = 0;				gwin->double_clicked(event.button.x >> scale, 						event.button.y >> scale);				if (gwin->get_mode() == Game_window::gump)					mouse->set_shape(Mouse::hand);				break;				}			last_b1_click = curtime;			if (!dragged)					// Identify item(s) clicked on.				gwin->show_items(event.button.x >> scale, 						event.button.y >> scale);			dragging = 0;			}		break;	case SDL_MOUSEMOTION:		{		mouse->move(event.motion.x >> scale, event.motion.y >> scale);		if (gwin->get_mode() == Game_window::normal)			Set_mouse_and_speed(event.motion.x, event.motion.y);		mouse_update = 1;	// Need to blit mouse.		if (gwin->get_mode() != Game_window::normal &&		    gwin->get_mode() != Game_window::gump)			break;					// Dragging with left button?		if (event.motion.state & SDL_BUTTON(1))			dragged = gwin->drag(event.motion.x >> scale, 						event.motion.y >> scale);					// Dragging with right?		if ((event.motion.state & SDL_BUTTON(3)) &&					// But not right after teleport.		    !gwin->was_teleported())			gwin->start_actor(event.motion.x >> scale, 					event.motion.y >> scale, avatar_speed);		break;		}	case SDL_ACTIVEEVENT:					// Get scale factor for mouse.		scale = gwin->get_win()->get_scale() == 2 ? 1 : 0;		if (event.active.state & SDL_APPMOUSEFOCUS)			{			if (event.active.gain)				{				int x, y;				SDL_GetMouseState(&x, &y);				mouse->set_location(x >> scale, y >> scale);				}			gwin->set_painted();			}		if (event.active.state & SDL_APPINPUTFOCUS)			{			if (event.active.gain)				gwin->get_focus();			else				gwin->lose_focus();			}		if (event.active.state & SDL_APPACTIVE)					// Became active.			if (event.active.gain)				gwin->init_actors();		break;#if 0	case ConfigureNotify:		// Resize.		gwin->resized(event.xconfigure.window,			event.xconfigure.width, event.xconfigure.height);		break;#endif	case SDL_QUIT:		Okay_to_quit();		break;	case SDL_KEYDOWN:		// Keystroke.		Handle_keystroke(event.key.keysym.sym,			event.key.keysym.mod & KMOD_SHIFT,			(event.key.keysym.mod & KMOD_ALT) || altkeys,			event.key.keysym.mod & KMOD_CTRL);		break;	case SDL_KEYUP:			// Key released.		switch (event.key.keysym.sym)			{		case SDLK_RALT:		// Right alt.		case SDLK_RMETA:			altkeys &= ~1;	// Clear flag.			break;		case SDLK_LALT:		case SDLK_LMETA:			altkeys &= ~2;			break;		default: break;			}		break;#if 0//#ifdef WIN32	case SDL_SYSWMEVENT://		printf("SYSWMEVENT received, %x\n", event.syswm.msg->msg);		if (event.syswm.msg->msg == MM_MCINOTIFY) {#if DEBUG			cerr << "MM_MCINOTIFY message received"<<endl;#endif			((Windows_MCI*)(Audio::get_ptr()->get_midi()))->callback(event.syswm.msg->wParam, 							event.syswm.msg->hwnd);		}		break;#endif		}	}