diff --git a/libs/FScreen.c b/libs/FScreen.c index a7742f660..86134050a 100644 --- a/libs/FScreen.c +++ b/libs/FScreen.c @@ -1412,4 +1412,4 @@ int FScreenFetchMangledScreenFromUSPosHints(XSizeHints *hints) screen = 0; return screen; -} +} \ No newline at end of file diff --git a/modules/FvwmRearrange/FvwmRearrange.c b/modules/FvwmRearrange/FvwmRearrange.c index 542fa2529..173ba787a 100644 --- a/modules/FvwmRearrange/FvwmRearrange.c +++ b/modules/FvwmRearrange/FvwmRearrange.c @@ -46,6 +46,7 @@ #include "fvwm/fvwm.h" #include "libs/vpacket.h" #include "libs/System.h" +#include "libs/Parse.h" typedef struct window_item { Window frame; @@ -82,14 +83,18 @@ int flatx = 0, flaty = 0; int incx = 0, incy = 0; int horizontal = 0; int maxnum = 0; +int current_desk = 0; int do_maximize = 0; int do_animate = 0; int do_ewmhiwa = 0; +int is_global = 0; int FvwmTile = 0; int FvwmCascade = 1; +char *monitor_name = NULL; +struct monitor *mon; RETSIGTYPE DeadPipe(int sig) { @@ -125,6 +130,7 @@ int is_suitable_window(unsigned long *body) { XWindowAttributes xwa; struct ConfigWinPacket *cfgpacket = (void *) body; + char *m_name = (char *)&(cfgpacket->monitor_name); if ((DO_SKIP_WINDOW_LIST(cfgpacket)) && !all) return 0; @@ -150,8 +156,10 @@ int is_suitable_window(unsigned long *body) if (IS_ICONIFIED(cfgpacket)) return 0; - if (!desk) - { + if (desk) { + if (!is_global && (int)cfgpacket->desk != current_desk) + return 0; + } else { int x = (int)cfgpacket->frame_x, y = (int)cfgpacket->frame_y; int w = (int)cfgpacket->frame_width, h = (int)cfgpacket->frame_height; if (x >= dx + dwidth || y >= dy + dheight || x + w <= dx || y + h <= dy) @@ -164,6 +172,9 @@ int is_suitable_window(unsigned long *body) if ((IS_TRANSIENT(cfgpacket)) && !transients) return 0; + if (!is_global && strcmp(mon->si->name, m_name) != 0) + return 0; + return 1; } @@ -250,28 +261,23 @@ void move_resize_raise_window( window_item *wi, int x, int y, int w, int h) { static char msg[78]; - const char *ewmhiwa = do_ewmhiwa ? - "ewmhiwa" : ""; + const char *ewmhiwa = do_ewmhiwa ? "ewmhiwa" : ""; if (resize) { - const char *function = do_maximize? - "ResizeMoveMaximize": - "ResizeMove"; - snprintf(msg, sizeof(msg), "%s %dp %dp %up %upi %s", function, w, h, x, y, - ewmhiwa); + const char *function = do_maximize ? + "ResizeMoveMaximize": "ResizeMove"; + snprintf(msg, sizeof(msg), "%s %dp %dp %up %up %s", + function, w, h, x, y, ewmhiwa); SendText(fd, msg, wi->frame); } else { - const char *function = do_maximize? - "ResizeMoveMaximize": - do_animate ? "AnimatedMove" : "Move"; - if (do_maximize) - snprintf(msg, sizeof(msg), "%s keep keep %up %up %s", function, x, y, - ewmhiwa); - else - snprintf(msg, sizeof(msg), "%s %up %up %s", function, x, y, ewmhiwa); + const char *function = do_maximize ? + "ResizeMoveMaximize keep keep" : do_animate ? + "AnimatedMove" : "Move"; + snprintf(msg, sizeof(msg), "%s %up %up %s", + function, x, y, ewmhiwa); SendText(fd, msg, wi->frame); } @@ -396,7 +402,7 @@ void cascade_windows(void) } } -void parse_args(char *s, int argc, char *argv[], int argi) +void parse_args(int argc, char *argv[], int argi) { int nsargc = 0; /* parse args */ @@ -494,11 +500,14 @@ void parse_args(char *s, int argc, char *argv[], int argi) else if (!strcmp(argv[argi], "-noanimate")) { do_animate = 0; } + else if (!strcmp(argv[argi], "-screen") && ((argi + 1) < argc)) { + monitor_name = fxstrdup(argv[++argi]); + } else { if (++nsargc > 4) { fprintf(console, - "%s: %s: ignoring unknown arg %s\n", - module->name, s, argv[argi]); + "%s: ignoring unknown arg %s\n", + module->name, argv[argi]); continue; } if (nsargc == 1) { @@ -514,10 +523,6 @@ void parse_args(char *s, int argc, char *argv[], int argi) } } } - ofsx += dx; - ofsy += dy; - maxx += dx; - maxy += dy; } int main(int argc, char *argv[]) @@ -550,17 +555,55 @@ int main(int argc, char *argv[]) FScreenInit(dpy); fd_width = GetFdWidth(); + /* Need to parse args first so we know what monitor to use. */ + parse_args(module->user_argc, module->user_argv, 0); + if (monitor_name && StrEquals(monitor_name, "g")) { + is_global = 1; + do_ewmhiwa = 1; /* Ignore hints for global monitor. */ + } + + mon = monitor_resolve_name(monitor_name ? monitor_name : "c"); + if (mon == NULL) + mon = monitor_get_current(); + + dx = mon->si->x; + dy = mon->si->y; + dwidth = mon->si->w; + dheight = mon->si->h; + ofsx += dx; + ofsy += dy; + maxx += dx; + maxy += dy; + strcpy(match, "*"); strcat(match, module->name); InitGetConfigLine(fd,match); - GetConfigLine(fd, &config_line); - while (config_line != NULL) + for (GetConfigLine(fd, &config_line); config_line != NULL; + GetConfigLine(fd, &config_line)) { - GetConfigLine(fd, &config_line); + char *token, *next, *mname; + int dummy, bs_top, bs_bottom, bs_left, bs_right; + + token = PeekToken(config_line, &next); + if (!StrEquals(token, "Monitor")) + continue; + + config_line = GetNextToken(next, &mname); + if (!StrEquals(mname, mon->si->name)) + continue; + + sscanf(config_line, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d", + &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, + &dummy, ¤t_desk, &dummy, &dummy, + &bs_left, &bs_right, &bs_top, &bs_bottom); + + if (!do_ewmhiwa) { + dx += bs_left; + dy += bs_top; + dwidth -= bs_right; + dheight -= bs_bottom; + } } - FScreenGetScrRect(NULL, FSCREEN_CURRENT, &dx, &dy, &dwidth, &dheight); - - parse_args("module args", module->user_argc, module->user_argv, 0); SetMessageMask(fd, M_CONFIGURE_WINDOW | @@ -592,5 +635,8 @@ int main(int argc, char *argv[]) if (console != stderr) fclose(console); + if (monitor_name) + free(monitor_name); + return 0; -} +} \ No newline at end of file