if (chr) *chr = 0; Mouse::Mouse_shapes saveshape = Mouse::mouse->get_shape(); if (shape != Mouse::dontchange) Mouse::mouse->set_shape(shape); if (paint) paint->paint(); Mouse::mouse->show(); gwin->show(1); gwin->get_tqueue()->pause(Game::get_ticks()); int ret = Get_click(x, y, chr, drag_ok, paint); gwin->get_tqueue()->resume(Game::get_ticks()); Mouse::mouse->set_shape(saveshape); return (ret);
dragging = false; while (1) { SDL_Event event; Delay();  uint32 ticks = SDL_GetTicks(); Game::set_ticks(ticks); Mouse::mouse->hide(); Mouse::mouse_update = false;   int scale = gwin->get_fastmouse() ? 1 : gwin->get_win()->get_scale();  static bool rightclick; while (SDL_PollEvent(&event)) switch (event.type) { case SDL_MOUSEBUTTONDOWN: if (event.button.button == 3) rightclick = true; else if (drag_ok && event.button.button == 1) { x = event.button.x / scale; y = event.button.y / scale; dragging = gwin->start_dragging(x, y); dragged = false; } break; case SDL_MOUSEBUTTONUP: if (event.button.button == 1) { x = event.button.x / scale; y = event.button.y / scale; bool drg = dragging, drged = dragged; dragging = dragged = false; if (!drg || !gwin->drop_dragged(x, y, drged)) { if (chr) *chr = 0; return (1); } } else if (event.button.button == 3) {  gwin->get_main_actor()->stop(); if (gwin->get_mouse3rd() && rightclick)						{ rightclick = false; return 0; } } break; case SDL_MOUSEMOTION: { int mx = event.motion.x / scale, my = event.motion.y / scale; Mouse::mouse->move(mx, my); Mouse::mouse_update = true; if (drag_ok && (event.motion.state & SDL_BUTTON(1))) dragged = gwin->drag(mx, my); break; } case SDL_KEYDOWN: {  int c = event.key.keysym.sym; switch(c) { case SDLK_ESCAPE: return 0; case SDLK_RSHIFT: case SDLK_LSHIFT: case SDLK_RCTRL: case SDLK_LCTRL: case SDLK_RALT: case SDLK_LALT: case SDLK_RMETA: case SDLK_LMETA: case SDLK_RSUPER: case SDLK_LSUPER: case SDLK_NUMLOCK: case SDLK_CAPSLOCK: case SDLK_SCROLLOCK: break; default: if ((c == 's') && (event.key.keysym.mod & KMOD_ALT) && (event.key.keysym.mod & KMOD_CTRL)){ make_screenshot(true); break; } if (chr) { *chr = (event.key.keysym.mod & KMOD_SHIFT) ? toupper(c) : c; return (1); } break; } break; } case SDL_ACTIVEEVENT: if (event.active.state & SDL_APPINPUTFOCUS) { if (event.active.gain) gwin->get_focus(); else gwin->lose_focus(); } } if (GL_manager::get_instance()) { gwin->paint(); if (paint) paint->paint(); } else if (dragging) gwin->paint_dirty(); Mouse::mouse->show(); if (!gwin->show() && Mouse::mouse_update) Mouse::mouse->blit_dirty(); } return (0);
int Get_click	(	int& x, int& y,			// Location returned (if not ESC).	Mouse::Mouse_shapes shape,	// Mouse shape to use.	char *chr,			// Char. returned if not null.	bool drag_ok,			// Okay to drag/close while here.	Paintable *paint		// Paint this over everything else.	)	{	if (chr)		*chr = 0;		// Init.	Mouse::Mouse_shapes saveshape = Mouse::mouse->get_shape();	if (shape != Mouse::dontchange)		Mouse::mouse->set_shape(shape);	if (paint)		paint->paint();	Mouse::mouse->show();	gwin->show(1);			// Want to see new mouse.	gwin->get_tqueue()->pause(Game::get_ticks());	int ret = Get_click(x, y, chr, drag_ok, paint);	gwin->get_tqueue()->resume(Game::get_ticks());	Mouse::mouse->set_shape(saveshape);	return (ret);	}