Skip to content

Commit

Permalink
FvwmRearrange: WIP
Browse files Browse the repository at this point in the history
Fixes #1033
  • Loading branch information
ThomasAdam committed Oct 13, 2024
1 parent 442a087 commit aeafd54
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
1 change: 1 addition & 0 deletions fvwm/move_resize.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ static int GetResizeArguments(
*paction = naction;

m = fw->m;
fprintf(stderr, "%s: USING MONITOR: %s\n", __func__, m->si->name);
n = 0;
n += ParseOneResizeArgument(
s1, monitor_get_all_widths(),
Expand Down
2 changes: 1 addition & 1 deletion libs/FScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1412,4 +1412,4 @@ int FScreenFetchMangledScreenFromUSPosHints(XSizeHints *hints)
screen = 0;

return screen;
}
}
59 changes: 46 additions & 13 deletions modules/FvwmRearrange/FvwmRearrange.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ int do_ewmhiwa = 0;
int FvwmTile = 0;
int FvwmCascade = 1;

char *monitor_name = NULL;

RETSIGTYPE DeadPipe(int sig)
{
Expand Down Expand Up @@ -125,6 +126,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;
Expand Down Expand Up @@ -164,6 +166,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 1;

return 1;
}

Expand Down Expand Up @@ -250,16 +255,22 @@ 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" : "";

/*
* Fvwm treats move arguments 'Xp' are relative to the current
* screen so we need to subtract dx and dy from the location.
*/
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);
fprintf(stderr, "Using: %s\n", function);
snprintf(msg, sizeof(msg), "%s %dp %dp %up %up %s",
function,
w, h, x - dx, y - dy, ewmhiwa);
fprintf(stderr, "SENDING: %s\n", msg);
SendText(fd, msg, wi->frame);
}
else
Expand All @@ -268,10 +279,12 @@ void move_resize_raise_window(
"ResizeMoveMaximize":
do_animate ? "AnimatedMove" : "Move";
if (do_maximize)
snprintf(msg, sizeof(msg), "%s keep keep %up %up %s", function, x, y,
ewmhiwa);
snprintf(msg, sizeof(msg), "%s keep keep %up %up %s", function,
x - dx, y - dy, ewmhiwa);
else
snprintf(msg, sizeof(msg), "%s %up %up %s", function, x, y, ewmhiwa);
snprintf(msg, sizeof(msg), "%s %up %up %s", function,
x - dx, y - dy, ewmhiwa);
fprintf(stderr, "SENDING: %s\n", msg);
SendText(fd, msg, wi->frame);
}

Expand Down Expand Up @@ -494,6 +507,10 @@ 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]);
fprintf(stderr, "MONITOR: %s\n", monitor_name);
}
else {
if (++nsargc > 4) {
fprintf(console,
Expand All @@ -514,10 +531,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[])
Expand Down Expand Up @@ -558,10 +571,30 @@ int main(int argc, char *argv[])
{
GetConfigLine(fd, &config_line);
}
FScreenGetScrRect(NULL, FSCREEN_CURRENT, &dx, &dy, &dwidth, &dheight);

parse_args("module args", module->user_argc, module->user_argv, 0);

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;

if (monitor_name != NULL) {
dx = m->si->x;
dy = m->si->y;
}

fprintf(stderr, "Using monitor: <%s>: {dx: %d, dy: %d, dwidth: %d, dheight: %d}\n",
m->si->name, dx, dy, dwidth, dheight);

SetMessageMask(fd,
M_CONFIGURE_WINDOW |
M_END_WINDOWLIST);
Expand Down Expand Up @@ -593,4 +626,4 @@ int main(int argc, char *argv[])
fclose(console);

return 0;
}
}

0 comments on commit aeafd54

Please sign in to comment.