Skip to content

Commit

Permalink
FvwmPager: ShapedLabels per-monitor aware.
Browse files Browse the repository at this point in the history
Make ShapedLabels show the labels of all desks any monitor
is currently in.
  • Loading branch information
somiaj authored and ThomasAdam committed Apr 28, 2024
1 parent 0b00a86 commit 9f37323
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 49 deletions.
2 changes: 0 additions & 2 deletions modules/FvwmPager/init_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,7 @@ void initialise_common_pager_fragments(void)

/* Check that shape extension exists. */
if (FHaveShapeExtension && ShapeLabels)
{
ShapeLabels = (FShapesSupported) ? 1 : 0;
}

/* Load pixmaps for mono use */
if (Pdepth < 2)
Expand Down
86 changes: 39 additions & 47 deletions modules/FvwmPager/x_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,58 +345,50 @@ void set_desk_size(bool update_label)

void UpdateWindowShape(void)
{
if (FHaveShapeExtension)
{
int i, j, cnt, shape_count, x_pos, y_pos;
XRectangle *shape;
struct fpmonitor *fp = fpmonitor_this(NULL);

if (!fp || !ShapeLabels || label_h == 0)
return;

shape_count =
ndesks + ((fp->m->virtual_scr.CurrentDesk < desk1 || fp->m->virtual_scr.CurrentDesk >desk2) ? 0 : 1);

shape = fxmalloc(shape_count * sizeof (XRectangle));

cnt = 0;
y_pos = (LabelsBelow ? 0 : label_h);
if (!ShapeLabels || label_h == 0 || fAlwaysCurrentDesk)
return;

for (i = 0; i < Rows; ++i)
{
x_pos = 0;
for (j = 0; j < Columns; ++j)
{
if (cnt < ndesks)
{
shape[cnt].x = x_pos;
shape[cnt].y = y_pos;
shape[cnt].width = desk_w + 1;
shape[cnt].height = desk_h + 2;
int i, j, cnt, x_pos, y_pos;
XRectangle *shape;
struct fpmonitor *fp;
shape = fxmalloc(ndesks * sizeof (XRectangle));

cnt = 0;
y_pos = (LabelsBelow) ? 0 : label_h;
for (i = 0; i < Rows; i++) {
x_pos = 0;
for (j = 0; j < Columns; j++) {
if (cnt >= ndesks)
continue;

if (cnt == fp->m->virtual_scr.CurrentDesk - desk1)
{
shape[ndesks].x = x_pos;
shape[ndesks].y =
(LabelsBelow ? y_pos + desk_h + 2 : y_pos - label_h);
shape[ndesks].width = desk_w;
shape[ndesks].height = label_h + 2;
}
/* Default shape/hide labels. */
shape[cnt].x = x_pos;
shape[cnt].y = y_pos;
shape[cnt].width = desk_w + 1;
shape[cnt].height = desk_h + 2;

/* Show labels for active monitors. */
TAILQ_FOREACH(fp, &fp_monitor_q, entry) {
if (fp->disabled ||
(monitor_to_track != NULL &&
monitor_to_track != fp) ||
cnt + desk1 !=
fp->m->virtual_scr.CurrentDesk)
continue;

shape[cnt].y -= (LabelsBelow) ? 0 : label_h;
shape[cnt].height += label_h;
}
cnt++;
x_pos += desk_w + 1;
}
y_pos += desk_h + 2 + label_h;
}
++cnt;
x_pos += desk_w + 1;
}
y_pos += desk_h + 2 + label_h;
}

FShapeCombineRectangles(
dpy, Scr.pager_w, FShapeBounding, 0, 0, shape, shape_count, FShapeSet, 0);
free(shape);
}
FShapeCombineRectangles(dpy, Scr.pager_w, FShapeBounding,
0, 0, shape, cnt, FShapeSet, 0);
free(shape);
}



/*
*
* Decide what to do about received X events
Expand Down

0 comments on commit 9f37323

Please sign in to comment.