Taskbar: better task monitor detection (issue #511)
This commit is contained in:
@@ -131,17 +131,28 @@ int window_get_monitor (Window win)
|
|||||||
Window src;
|
Window src;
|
||||||
|
|
||||||
XTranslateCoordinates(server.dsp, win, server.root_win, 0, 0, &x, &y, &src);
|
XTranslateCoordinates(server.dsp, win, server.root_win, 0, 0, &x, &y, &src);
|
||||||
x += 2;
|
int best_match = -1;
|
||||||
y += 2;
|
int match_right = 0;
|
||||||
|
int match_bottom = 0;
|
||||||
|
// There is an ambiguity when a window is right on the edge between screens.
|
||||||
|
// In that case, prefer the monitor which is on the right and bottom of the window's top-left corner.
|
||||||
for (i = 0; i < server.nb_monitor; i++) {
|
for (i = 0; i < server.nb_monitor; i++) {
|
||||||
if (x >= server.monitor[i].x && x <= (server.monitor[i].x + server.monitor[i].width))
|
if (x >= server.monitor[i].x && x <= (server.monitor[i].x + server.monitor[i].width))
|
||||||
if (y >= server.monitor[i].y && y <= (server.monitor[i].y + server.monitor[i].height))
|
if (y >= server.monitor[i].y && y <= (server.monitor[i].y + server.monitor[i].height)) {
|
||||||
break;
|
int current_right = x < (server.monitor[i].x + server.monitor[i].width);
|
||||||
|
int current_bottom = y < (server.monitor[i].y + server.monitor[i].height);
|
||||||
|
if (best_match < 0 ||
|
||||||
|
(!match_right && current_right) ||
|
||||||
|
(!match_bottom && current_bottom)) {
|
||||||
|
best_match = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("window %lx : ecran %d, (%d, %d)\n", win, i, x, y);
|
if (best_match < 0)
|
||||||
if (i == server.nb_monitor) return 0;
|
best_match = 0;
|
||||||
else return i;
|
// printf("window %lx : ecran %d, (%d, %d)\n", win, best_match+1, x, y);
|
||||||
|
return best_match;
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_get_coordinates (Window win, int *x, int *y, int *w, int *h)
|
void window_get_coordinates (Window win, int *x, int *y, int *w, int *h)
|
||||||
|
|||||||
Reference in New Issue
Block a user