2
#include <grass/raster.h>
3
#include <grass/display.h>
5
int ident_win(char *cur_pad)
18
/* Get list of pads (windows) */
19
R_pad_list(&pads, &npads);
23
x = (R_screen_rite() + R_screen_left()) / 2;
24
y = (R_screen_top() + R_screen_bot()) / 2;
30
R_get_location_with_pointer(&x, &y, &button);
31
for (p = 0; p < npads; p++) {
35
stat = R_pad_select(pads[p]);
37
R_pad_perror("ERROR", stat);
41
/* Check each window's "d_win" */
42
stat = R_pad_get_item("d_win", &list, &count);
44
R_pad_perror("ERROR", stat);
47
sscanf(list[0], "%d %d %d %d", &t, &b, &l, &r);
48
R_pad_freelist(list, count);
50
/* If chosen point is outside pad window, continue */
51
if (x < l || x > r || y < t || y > b)
54
/* If right edge closer than closest, the save pad name */
55
if ((r - x) >= 0 && (r - x) < closest) {
58
strcpy(cur_pad, pads[p]);
63
D_set_cur_wind(cur_pad);