void mouse_press(int x,int y,char button) { component *cur = recurse_press(main_panel,x,y,button); if (last_pressed != cur) { if (last_pressed) { int *loc = getRelativeLocation(last_pressed,x,y); blur_array[(unsigned char)last_pressed->type](last_pressed,loc[0],loc[1],button); } } last_pressed = cur; press = 1; }
void mouse_move(int x,int y,char button) { /*if (press && last_pressed) { component *cur = last_pressed; for (;cur;cur = cur->parent) { x -= cur->x; y -= cur->y; } mouse_move_array[(unsigned char)last_pressed->type](last_pressed,x,y,button); return; }*/ component *cur = recurse_move(main_panel,x,y,button); if (cur != inside) { if (inside) { int *loc = getRelativeLocation(inside,x,y); mouse_leave_array[(unsigned char)inside->type](inside,loc[0],loc[1],button); } inside = cur; } }
/********************************************************************************* * Returns the location in the traceFile of the trace data (time stamp and cpid) * Precondition: the location of the trace data is between minLoc and maxLoc. * @param time: the time to be found * @param left_boundary_offset: the start location. 0 means the beginning of the data in a process * @param right_boundary_offset: the end location. ********************************************************************************/ FileOffset TraceDataByRank::findTimeInInterval(Time time, FileOffset l_boundOffset, FileOffset r_boundOffset) { if (l_boundOffset == r_boundOffset) return l_boundOffset; FileOffset l_index = getRelativeLocation(l_boundOffset); FileOffset r_index = getRelativeLocation(r_boundOffset); Time l_time = data->getLong(l_boundOffset); Time r_time = data->getLong(r_boundOffset); // apply "Newton's method" to find target time while (r_index - l_index > 1) { FileOffset predicted_index; //pat2 7/1/13: We only ever divide by rate, and double multiplication //is faster than division (confirmed with a benchmark) so compute inverse //rate instead. This line of code and the one in the else block account for //about 40% of the computation once the data is in memory //double rate = (r_time - l_time) / (r_index - l_index); double invrate = (r_index - l_index) / (r_time - l_time); Time mtime = (r_time - l_time) / 2; if (time <= mtime) { predicted_index = max((Long) ((time - l_time) * invrate) + l_index, l_index); } else { predicted_index = min((r_index - (long) ((r_time - time) * invrate)), r_index); } // adjust so that the predicted index differs from both ends // except in the case where the interval is of length only 1 // this helps us achieve the convergence condition if (predicted_index <= l_index) predicted_index = l_index + 1; if (predicted_index >= r_index) predicted_index = r_index - 1; Time temp = data->getLong(getAbsoluteLocation(predicted_index)); if (time >= temp) { l_index = predicted_index; l_time = temp; } else { r_index = predicted_index; r_time = temp; } } FileOffset l_offset = getAbsoluteLocation(l_index); FileOffset r_offset = getAbsoluteLocation(r_index); l_time = data->getLong(l_offset); r_time = data->getLong(r_offset); int leftDiff = time - l_time; int rightDiff = r_time - time; bool is_left_closer = abs(leftDiff) < abs(rightDiff); if (is_left_closer) return l_offset; else if (r_offset < maxloc) return r_offset; else return maxloc; }