static PyObject* python_recenter_button_pressed(PyObject* self, PyObject* args) { int arg_canvas_x; int arg_canvas_y; if(PyArg_ParseTuple(args, "ii", &arg_canvas_x, &arg_canvas_y) == 0) return NULL; recenter_button_pressed(arg_canvas_x, arg_canvas_y); return Py_BuildValue("i", 0); }
/************************************************************************** ... **************************************************************************/ void mapctrl_btn_mapcanvas(XEvent *event) { XButtonEvent *ev=&event->xbutton; struct tile *ptile = canvas_pos_to_tile(ev->x, ev->y); if (!can_client_change_view()) { return; } if (ev->button == Button1 && (ev->state & ControlMask)) { action_button_pressed(ev->x, ev->y, SELECT_SEA); } else if (ev->button == Button1) { action_button_pressed(ev->x, ev->y, SELECT_POPUP); } else if (ev->button == Button2 && ptile) { popit(ev->x, ev->y, ptile); } else if (ev->button == Button3 && (ev->state & ControlMask)) { action_button_pressed(ev->x, ev->y, SELECT_LAND); } else if (ev->button == Button3) { recenter_button_pressed(ev->x, ev->y); } }
JNIEXPORT jboolean JNICALL Java_net_hackcasual_freeciv_NativeHarness_touchEvent (JNIEnv *je, jobject o, jint x, jint y, jint type) { struct timeval tvs, tve; int nif = 0; static int oldx = -1; static int oldy = -1; lastTouchX = x; lastTouchY = y; int deltax; int deltay; static bool cancelUp; struct tile *plasttile; switch (type) { case 0: { cancelUp = FALSE; oldx = x; oldy = y; plasttile = canvas_pos_to_tile(x,y); break; } case 1: { if (!cancelUp && abs(x - oldx) < 10 && abs(y - oldy) < 10) { can_slide = FALSE; LOGI("ABP Lock"); civ_lock(); action_button_pressed(x,y,SELECT_POPUP); can_slide = TRUE; flush_dirty(); struct tile *ptile = canvas_pos_to_tile(x,y); civ_unlock(); return (ptile && ptile->units)?unit_list_size(ptile->units):0; } else if (!cancelUp) { LOGI("Recenter Lock"); civ_lock(); can_slide = FALSE; recenter_button_pressed(x, y); can_slide = TRUE; flush_dirty(); civ_unlock(); } break; } case 2: { /*hover_state = HOVER_GOTO; control_mouse_cursor(canvas_pos_to_tile(x,y)); update_line(x,y); break;*/ if (cancelUp || abs(x - oldx) > 10 || abs(y - oldy) > 10) { cancelUp = TRUE; LOGI("Slide Lock"); civ_lock(); can_slide = FALSE; deltax = oldx - x; deltay = oldy - y; set_mapview_origin(mapview.gui_x0 + deltax, mapview.gui_y0 + deltay); flush_dirty(); civ_unlock(); oldx = x; oldy = y; can_slide = TRUE; } break; } case 3: { cancelUp = TRUE; break; } } return 0; }