all repos — tint2 @ 23e740c7f1d9ab6cda7f1f55d7c463f7bba1301c

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Fix compiz support with multiple desktops and monitors
o9000 mrovi9000@gmail.com
commit

23e740c7f1d9ab6cda7f1f55d7c463f7bba1301c

parent

10ca7f076206d3d3e3973de1ef148902b561b067

1 files changed, 28 insertions(+), 6 deletions(-)

jump to
M src/util/window.csrc/util/window.c

@@ -153,22 +153,44 @@ }

if (best_match < 0) best_match = 0; - // printf("window %lx : viewport %d, (%d, %d)\n", win, best_match+1, x, y); + //fprintf(stderr, "window %lx %s : viewport %d, (%d, %d)\n", win, get_task(win) ? get_task(win)->title : "??", best_match+1, x, y); return best_match; } int get_window_monitor(Window win) { - int i, x, y; - Window src; + int x, y, w, h; + get_window_coordinates(win, &x, &y, &w, &h); + + if (server.viewports) { + int desktop = MIN(get_current_desktop(), server.num_desktops - 1); + // Window coordinates are relative to the current viewport, make them absolute + x += server.viewports[desktop].x; + y += server.viewports[desktop].y; - XTranslateCoordinates(server.display, win, server.root_win, 0, 0, &x, &y, &src); + if (x < 0 || y < 0) { + int num_results; + long *x_screen_size = server_get_property(server.root_win, server.atom._NET_DESKTOP_GEOMETRY, XA_CARDINAL, &num_results); + if (!x_screen_size) + return 0; + int x_screen_width = x_screen_size[0]; + int x_screen_height = x_screen_size[1]; + XFree(x_screen_size); + + // Wrap + if (x < 0) + x += x_screen_width; + if (y < 0) + y += x_screen_height; + } + } + int best_match = -1; 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.num_monitors; i++) { + for (int i = 0; i < server.num_monitors; i++) { if (x >= server.monitors[i].x && x <= (server.monitors[i].x + server.monitors[i].width) && y >= server.monitors[i].y && y <= (server.monitors[i].y + server.monitors[i].height)) { int current_right = x < (server.monitors[i].x + server.monitors[i].width);

@@ -181,7 +203,7 @@ }

if (best_match < 0) best_match = 0; - // printf("window %lx : ecran %d, (%d, %d)\n", win, best_match+1, x, y); + // fprintf(stderr, "desktop %d, window %lx %s : monitor %d, (%d, %d)\n", 1 + get_current_desktop(), win, get_task(win) ? get_task(win)->title : "??", best_match+1, x, y); return best_match; }