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..81272ee07 100644 --- a/modules/FvwmRearrange/FvwmRearrange.c +++ b/modules/FvwmRearrange/FvwmRearrange.c @@ -46,11 +46,13 @@ #include "fvwm/fvwm.h" #include "libs/vpacket.h" #include "libs/System.h" +#include "libs/Parse.h" typedef struct window_item { Window frame; - int th, bw; + int th, bw, desk; unsigned long width, height; + struct monitor *m; struct window_item *prev, *next; } window_item, *window_list; @@ -82,6 +84,7 @@ 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; @@ -90,6 +93,7 @@ int do_ewmhiwa = 0; int FvwmTile = 0; int FvwmCascade = 1; +char *monitor_name = NULL; RETSIGTYPE DeadPipe(int sig) { @@ -125,6 +129,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 +155,10 @@ int is_suitable_window(unsigned long *body) if (IS_ICONIFIED(cfgpacket)) return 0; - if (!desk) - { + if (desk) { + if ((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 +171,9 @@ int is_suitable_window(unsigned long *body) if ((IS_TRANSIENT(cfgpacket)) && !transients) return 0; + if (monitor_name != NULL && (strcmp(monitor_name, m_name) != 0)) + return 0; + return 1; } @@ -183,6 +193,11 @@ int get_window(void) else { cfgpacket = (struct ConfigWinPacket*) packet->body; switch (packet->type &= ~M_EXTENDED_MSG) { + case M_CONFIG_INFO: + unsigned long* body = packet->body; + fprintf(stderr, "CONFIG_INFO: %s", (char *)&body[3]); + last = 1; + break; case M_CONFIGURE_WINDOW: if (is_suitable_window(packet->body)) { window_item *wi = @@ -192,6 +207,8 @@ int get_window(void) wi->bw = cfgpacket->border_width; wi->width = cfgpacket->frame_width; wi->height = cfgpacket->frame_height; + wi->desk = cfgpacket->desk; + wi->m = monitor_by_output(cfgpacket->monitor_id); if (!wins_tail) wins_tail = wi; insert_window_list(&wins, wi); ++wins_count; @@ -250,28 +267,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 +408,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 +506,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 +529,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 +561,53 @@ 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")) + do_ewmhiwa = 1; /* Ignore hints for global monitor. */ + + struct monitor *m = monitor_resolve_name(monitor_name ? monitor_name : "c"); + if (m == NULL) + m = monitor_get_current(); + + dx = m->si->x; + dy = m->si->y; + dwidth = m->si->w; + dheight = m->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, m->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 | @@ -593,4 +640,4 @@ int main(int argc, char *argv[]) fclose(console); return 0; -} +} \ No newline at end of file