Skip to content

Commit

Permalink
Expansion: add $[w.pagex] $[w.pagey]
Browse files Browse the repository at this point in the history
This adds expansion parameters to determine which page a window is on.

Fixes #255
  • Loading branch information
ThomasAdam committed Oct 15, 2020
1 parent 264eaf1 commit a02c4ee
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/fvwm/expansion.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ command can be used:</para>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$[w.pagex] $[w.pagey]</term>
<listitem><para>The X or Y page the window is on.</para></listitem>
</varlistentry>
<varlistentry>
<term>$[w.desk]</term>
<listitem>
Expand Down
38 changes: 38 additions & 0 deletions fvwm/expand.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ static char *function_vars[] =
"w.desk",
"w.layer",
"w.screen",
"w.pagex",
"w.pagey",
/* ewmh working area */
"wa.height",
"wa.width",
Expand Down Expand Up @@ -225,6 +227,8 @@ enum
VAR_W_DESK,
VAR_W_LAYER,
VAR_W_SCREEN,
VAR_W_PAGEX,
VAR_W_PAGEY,
/* ewmh working area */
VAR_WA_HEIGHT,
VAR_WA_WIDTH,
Expand Down Expand Up @@ -955,6 +959,40 @@ static signed int expand_vars_extended(
should_quote = False;
}
break;
case VAR_W_PAGEX:
case VAR_W_PAGEY: {
int wx, wy, wh, ww, page_x, page_y;
rectangle r, t;
Window win;

if (!fw || IS_EWMH_DESKTOP(FW_W(fw))) {
return -1;
}

win = FW_W_FRAME(fw);
if (!XGetGeometry(dpy, win, &JunkRoot, &wx, &wy,
(unsigned int*)&ww,
(unsigned int*)&wh,
(unsigned int*)&JunkBW,
(unsigned int*)&JunkDepth)) {
return -1;
}
r.x = wx;
r.y = wy;
r.width = ww;
r.height = wh;

get_absolute_geometry(fw, &t, &r);
get_page_offset_rectangle(fw, &page_x, &page_y, &t);

if (i == VAR_W_PAGEX)
val = page_x / monitor_get_all_widths();
else
val = page_y / monitor_get_all_heights();
is_numeric = True;
should_quote = False;
break;
}
case VAR_SCREEN:
is_numeric = False;
val = Scr.screen;
Expand Down
1 change: 1 addition & 0 deletions fvwm/move_resize.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "move_resize.h"
#include "functions.h"
#include "style.h"
#include "externs.h"

/* ----- move globals ----- */

Expand Down

0 comments on commit a02c4ee

Please sign in to comment.